Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. from sklearn.metrics import f1_score, accuracy_score
  2. ground_truth = [r[1] for r in testing_set]
  3. predictions = {}
  4. f1_scores = {}
  5. f
  6. or clf, listy in classifiers_dict.items():
  7. # getting predictions for the testing set by looping over each reviews featureset tuple
  8. # The first elemnt of the tuple is the feature set and the second element is the label
  9. predictions[clf] = [listy[0].classify(r[0]) for r in testing_set]
  10. f1_scores[clf] = f1_score(ground_truth, predictions[clf])
  11. print(f'f1_score {clf}: {f1_scores[clf]}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement