Created
May 1, 2022 06:12
-
-
Save charlieoneill11/6d41e35fbe8e21497aa7b7b220b9293d 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
from sklearn.metrics import accuracy_score, f1_score | |
def compute_metrics(pred): | |
labels = pred.label_ids | |
preds = pred.predictions.argmax(-1) | |
f1 = f1_score(labels, preds, average="weighted") | |
acc = accuracy_score(labels, preds) | |
return {"accuracy": acc, "f1": f1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment