Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: continuous format is not supported in RidgeClassifierCV #6592

Closed
mithrandir4859 opened this issue Mar 26, 2016 · 3 comments
Closed

Comments

@mithrandir4859
Copy link

If you run the following code:

import numpy as np
from sklearn.linear_model.ridge import RidgeClassifierCV

classifier = RidgeClassifierCV(scoring='roc_auc')
x = np.array([[1, 2, 3], [3, 4, 9], [4, 9, 1], [8, 0, 4], [1, 1, 4], [1.1, 2, 4]])
y = np.array([True, False, True, False, True, False])
classifier.fit(x, y)

You get the exception: ValueError: continuous format is not supported with the stacktrace:

File "E:/myfolder/cv_issue.py", line 7, in classifier.fit(x, y)
File "E:\Anaconda2\lib\site-packages\sklearn\linear_model\ridge.py", line 1258, in fit
_BaseRidgeCV.fit(self, X, Y, sample_weight=sample_weight)
File "E:\Anaconda2\lib\site-packages\sklearn\linear_model\ridge.py", line 1022, in fit
estimator.fit(X, y, sample_weight=sample_weight)
File "E:\Anaconda2\lib\site-packages\sklearn\linear_model\ridge.py", line 965, in fit
for i in range(len(self.alphas))]
File "E:\Anaconda2\lib\site-packages\sklearn\metrics\scorer.py", line 159, in call
raise ValueError("{0} format is not supported".format(y_type))
ValueError: continuous format is not supported

But, obviously, I provided a binary output so I don't expect such error here. And if you replace RidgeClassifierCV(scoring='roc_auc') with a RidgeClassifierCV(scoring='roc_auc', cv=2), the code runs fine.

My versions:

Windows-8.1-6.3.9600
('Python', '2.7.11 |Anaconda 2.5.0 (64-bit)| (default, Jan 29 2016, 14:26:21) [MSC v.1500 64 bit (AMD64)]')
('NumPy', '1.10.4')
('SciPy', '0.17.0')
('Scikit-Learn', '0.17')

@maniteja123
Copy link
Contributor

Hi, it seems that the values being passed to the scorer in here are y and cv_values[:,i] are passed as y_true and y_score for roc_auc_score, but in the scorer, _ThresholdScorer takes arguments X and y which now correspond to y_true and y_score in your case are

[ 1. -1.  1. -1.  1. -1.] 
[ 0.45824999 -1.64622488  0.6707735  -0.74680963  0.07694918  0.49169546]

Thus the check of y_type is raising an error of continuous type. I am not sure if this is the expected behavior in here since Threshold scorer was designed with this intent. Sorry can't be of much help here.

@amueller
Copy link
Member

"roc_auc" is a classification or ranking metric, not a regression metric. So it doesn't accept continuous y.

@aleksod
Copy link

aleksod commented Feb 14, 2020

I believe the OP stated that his targets were discrete, not continuous. I am also getting the same error with targets being discrete, 0s and 1s only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants