Skip to content

Instantly share code, notes, and snippets.

@nsorros
Created February 14, 2022 10:43
Show Gist options
  • Save nsorros/1f60e2a832dc35a5c840ce13bc153c58 to your computer and use it in GitHub Desktop.
Save nsorros/1f60e2a832dc35a5c840ce13bc153c58 to your computer and use it in GitHub Desktop.
def f(Y_pred_proba, Y_test, thresholds):
Y_pred = Y_pred_proba > thresholds
mlcm = multilabel_confusion_matrix(Y_test, Y_pred)
cm = mlcm.sum(axis=0)
tn, fp, fn, tp = cm.ravel()
f1 = tp / ( tp+ (fp+fn) / 2)
return f1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment