-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
38 lines (28 loc) · 932 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pandas as pd
from inference.rulebased import calculate_score
from inference.llm import llmApproach
from inference.mlClassifier import mlApproach
from tqdm import tqdm
df = pd.read_csv('training/english.csv')
rule_scores = []
llm_results = []
ml_results = []
combined_results = []
for index, row in tqdm(df.iterrows(), total=df.shape[0], desc="Processing prompts"):
prompt = row['text']
rule_score = calculate_score(prompt)
llm_result = llmApproach(prompt)
ml_result = mlApproach(prompt)
rule_scores.append(rule_score)
llm_results.append(llm_result)
ml_results.append(ml_result)
if (llm_result or ml_result) and (rule_score > 0):
combined_results.append(1)
else:
combined_results.append(0)
df['rule'] = rule_scores
df['ml'] = ml_results
df['llm'] = llm_results
df['combined'] = combined_results
df.to_csv('test.csv', index=False)
print("Output saved to test.csv")