Skip to content

Instantly share code, notes, and snippets.

@aswalin
Last active July 1, 2018 19:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aswalin/4cbab393ac9cbc17d51972473bd28683 to your computer and use it in GitHub Desktop.
Save aswalin/4cbab393ac9cbc17d51972473bd28683 to your computer and use it in GitHub Desktop.
from sklearn import metrics
import numpy as np
y_true = np.concatenate((np.ones(100), np.zeros(900)))
a = np.random.uniform(0.5,1, 5)
b = np.random.uniform(0,0.5, 995)
y_pred1 = np.concatenate((a,b))
a = np.random.uniform(0.5,1, 90)
b = np.random.uniform(0,0.5, 910)
y_pred2 = np.concatenate((a,b))
print(metrics.f1_score(y_true, y_pred1>0.5))
print(metrics.f1_score(y_true, y_pred2>0.5))
print(metrics.roc_auc_score(y_true, y_pred1))
print(metrics.roc_auc_score(y_true, y_pred2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment