Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Misleading variable name for the example of AUC calculation #29823

@bagustris

Description

@bagustris

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions