Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

evaluate.py 993 B

You have to be logged in to leave a comment. Sign In
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
  1. import argparse
  2. import pandas as pd
  3. from sklearn.metrics import f1_score, accuracy_score
  4. import json
  5. if __name__ == '__main__':
  6. parser = argparse.ArgumentParser()
  7. parser.add_argument("--predictions", type=str, required=True, help="Path to train dataset")
  8. parser.add_argument("--reference", type=str, required=True, help="Path to train dataset")
  9. parser.add_argument("--target_column", type=str, required=True, help="Column with classname")
  10. parser.add_argument("--result_file", type=str, required=True, help="Path to result file (in json)")
  11. args = parser.parse_args()
  12. # Load train dataset
  13. predictions = pd.read_csv(args.predictions)[args.target_column]
  14. trues = pd.read_csv(args.reference)[args.target_column]
  15. f1 = f1_score(trues, predictions, average='macro')
  16. accuracy = accuracy_score(trues, predictions)
  17. with open(args.result_file, 'w') as f:
  18. json.dump({
  19. 'accuracy': accuracy,
  20. 'f1': f1
  21. }, f, indent=4)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...