|
import json |
|
import sys |
|
from sklearn.metrics import accuracy_score, f1_score |
|
|
|
|
|
if len(sys.argv) != 2: |
|
print("Usage: python script.py <jsonl_file>") |
|
sys.exit(1) |
|
|
|
|
|
targets = [] |
|
predictions = [] |
|
|
|
|
|
filename = sys.argv[1] |
|
with open(filename, 'r') as f: |
|
for line in f: |
|
obj = json.loads(line) |
|
targets.append(obj['target']) |
|
predictions.append(obj['prediction']) |
|
|
|
|
|
targets = [int(x) for x in targets] |
|
predictions = [int(x) for x in predictions] |
|
|
|
|
|
accuracy = accuracy_score(targets, predictions) |
|
f1_macro = f1_score(targets, predictions, average='macro') |
|
f1_micro = f1_score(targets, predictions, average='micro') |
|
|
|
|
|
print(f"Accuracy: {accuracy}") |
|
print(f"F1 Macro: {f1_macro}") |
|
print(f"F1 Micro: {f1_micro}") |
|
|
|
|