Skip to content

Instantly share code, notes, and snippets.

@debonx
Created November 12, 2018 11:00
Show Gist options
  • Save debonx/98aca4c9c011b7ce74262bd315033690 to your computer and use it in GitHub Desktop.
Save debonx/98aca4c9c011b7ce74262bd315033690 to your computer and use it in GitHub Desktop.
Analyse the predictive power of your algorithm with Scikit-Learn. More at https://scikit-learn.org/
from sklearn.metrics import accuracy_score, recall_score, precision_score, f1_score
#True labels and predicted classifications
labels = [1, 0, 0, 1, 1, 1, 0, 1, 1, 1]
guesses = [0, 1, 1, 1, 1, 0, 1, 0, 1, 0]
#Calculate accuracy, recall, precision and f1 score
print(accuracy_score(labels, guesses))
print(recall_score(labels, guesses))
print(precision_score(labels, guesses))
print(f1_score(labels, guesses))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment