-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Closed
Labels
Description
Describe the issue linked to the documentation
In the example of AUC calculation, it was given that:
import numpy as np
from sklearn import metrics
y = np.array([1, 1, 2, 2])
pred = np.array([0.1, 0.4, 0.35, 0.8])
fpr, tpr, thresholds = metrics.roc_curve(y, pred, pos_label=2)
metrics.auc(fpr, tpr)Readers will assume that pred is the prediction value. In fact, it should be the prediction probabilities, as required by roc_curve.
Suggest a potential alternative/fix
Instead of using y and pred, giving the same name as required by roc_curve would be helpful.
import numpy as np
from sklearn import metrics
y_true = np.array([1, 1, 2, 2])
y_score = np.array([0.1, 0.4, 0.35, 0.8])
fpr, tpr, thresholds = metrics.roc_curve(y_true, y_score, pos_label=2)
metrics.auc(fpr, tpr)