Skip to content

wrong AUC #3950

Closed
Closed

Description

@IraKorshunova

Here is an example, when auc is calculated wrong:

import numpy as np
from sklearn.metrics import roc_curve, auc
p = np.array([3E-011, 5E-11, 2E-010, 1E-008, 2E-006, 1.29E-005, 0.0003, 0.1, 0.2, 0.3, 0.46])
p = np.expand_dims(p, axis=1)
y = np.array([0, 0,  0, 1,  0, 0, 1, 1, 1, 1, 1])
fpr, tpr, thresholds = roc_curve(y, p, pos_label=1)
roc_auc = auc(fpr, tpr)

with these values it should be 0.9333333 (I checked it in R), but sklearn gives 0.883333333333.
If I rescale p with MinMaxScaler(), I get the right answer.
I also noticed that it has different number of n_thresholds:
in the first case n_thresholds=8, and when I scale the probabilities n_thresholds=9.
Thank you very much for considering this problem!

Activity

  1. jnothman commented on Dec 10, 2014

    @jnothman
    Member

    duplicate of #3864.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions