Skip to content

Instantly share code, notes, and snippets.

@charlieoneill11
Created May 1, 2022 06:12
Show Gist options
  • Save charlieoneill11/6d41e35fbe8e21497aa7b7b220b9293d to your computer and use it in GitHub Desktop.
Save charlieoneill11/6d41e35fbe8e21497aa7b7b220b9293d to your computer and use it in GitHub Desktop.
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