5

I am trying to use the sklearn function RocCurveDisplay.from_predictions as presented in https://scikit-learn.org/stable/modules/generated/sklearn.metrics.RocCurveDisplay.html#sklearn.metrics.RocCurveDisplay.from_predictions. I run the function like this:

from sklearn.metrics import RocCurveDisplay

true = np.array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
       1., 1., 1., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0.])

prediction = np.array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 0., 0., 0.,
       1., 1., 1., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 1., 1., 0., 0.])

RocCurveDisplay.from_predictions(true,prediction)
plt.show()

I get the error message "AttributeError: type object 'RocCurveDisplay' has no attribute 'from_predictions' ".

Is this a version problem? I am using the latest one, 0.24.1

Julithe
  • 53
  • 1
  • 1
  • 3

1 Answers1

7

Your version 0.24.1 is not the latest version, You'll need to upgrade to scikit-learn 1.0 as from_predictions is supported in 1.0

You can upgrade using:

pip install --upgrade scikit-learn
The Singularity
  • 2,428
  • 3
  • 19
  • 48
  • 3
    It's worth mentioning that this version is only supported for python 3.7 and above – M.F Dec 29 '21 at 13:47