# Should I use predict_proba or predict when computing metrics

I need to compute some metrics for binary classification. I see that many times some people use the probability:

y_pred_proba = clf.fit(X_train, y_train).predict_proba(X_test)
roc_auc_score(y_test, y_pred_proba[:,1]) # probability of Class 1


and other times:

y_pred = clf.fit(X_train, y_train).predict(X_test)
roc_auc_score(y_test, y_pred) # binary outcome y_pred


if I try both I get completely different results.

Can anyone explain me which one has to be used with metrics score, if predict or predict_proba?

• AUROC requires probabilities of the predictions, not classes. Your second approach is wrong. – user2974951 Jan 25 at 8:30
• great! many thanks, is this true for all the metrics? f1_score, recall_score etc.? – Luigi87 Jan 25 at 8:31
• No. F1, recall and similar require classes. Obligatory reference, because someone will link it eventually, Why is accuracy not the best measure for assessing classification models?. – user2974951 Jan 25 at 8:34
• ok great! if you are willing to answer I will vote up your answer! – Luigi87 Jan 25 at 8:35

AUROC is a semi-proper scoring rules and actually uses the raw probabilities to calculate the best threshold to differentiate the two classes, that is in comparison to a default call to predict, which uses the "non-informative" threshold of 0.5.