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 807 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
26
27
28
29
30
31
  1. from sklearn.metrics import precision_recall_curve
  2. import sys
  3. import sklearn.metrics as metrics
  4. import conf
  5. try: import cPickle as pickle # python2
  6. except: import pickle # python3
  7. model_file = conf.model
  8. test_matrix_file = conf.test_matrix
  9. metrics_file = 'data/eval.txt'
  10. with open(model_file, 'rb') as fd:
  11. model = pickle.load(fd)
  12. with open(test_matrix_file, 'rb') as fd:
  13. matrix = pickle.load(fd)
  14. labels = matrix[:, 1].toarray()
  15. x = matrix[:, 2:]
  16. predictions_by_class = model.predict_proba(x)
  17. predictions = predictions_by_class[:,1]
  18. precision, recall, thresholds = precision_recall_curve(labels, predictions)
  19. auc = metrics.auc(recall, precision)
  20. #print('AUC={}'.format(metrics.auc(recall, precision)))
  21. with open(metrics_file, 'w') as fd:
  22. fd.write('AUC: {:4f}\n'.format(auc))
Tip!

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

Comments

Loading...