Created
November 19, 2022 11:43
-
-
Save keitazoumana/d8c2ce7ec3acc7a6144142ae166df28d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Individual imports | |
""" | |
from sklearn.metrics import precision_score, recall_score, f1_score | |
y_true = [0, 1, 2, 0, 1, 2] | |
y_pred = [0, 2, 1, 0, 0, 1] | |
print("Precision: ", precision_score(y_true, y_pred, average='macro')) | |
print("Recall: ", recall_score(y_true, y_pred, average='macro')) | |
print("F1 Score: ", f1_score(y_true, y_pred, average='macro')) | |
""" | |
Single Line import | |
""" | |
from sklearn.metrics import precision_recall_fscore_support | |
precision, recall, f1_score, _ = precision_recall_fscore_support(y_true, | |
y_pred, | |
average='macro') | |
print(f"Precision: {precision}") | |
print(f"Recall: {recall}") | |
print(f"F1 Score: {f1_score}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment