You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
'cross_val_predict' throws error when estimator is 'OneVsRest Classifier' and method is 'decision_function' #11058
'cross_val_predict' function throws error when estimator is 'OneVsRest Classifier with LinearSVC' and method is 'decision_function'.
Steps/Code to Reproduce
from sklearn.model_selection import cross_val_predict
from sklearn import svm
from sklearn.multiclass import OneVsRestClassifier
from sklearn.preprocessing import MultiLabelBinarizer
import numpy as np
I have a similar issue with the predict_proba method. Running the following
importnumpyasnpfromsklearn.ensembleimportGradientBoostingClassifierfromsklearn.model_selectionimportcross_val_predictfromsklearn.multiclassimportOneVsRestClassifierfromsklearn.preprocessingimportMultiLabelBinarizerX=np.random.rand(1000, 10)
y=np.random.randint(5, size= (1000, 1))
y=MultiLabelBinarizer().fit_transform(y) # cross_val_predict succeeds with this removedclf=OneVsRestClassifier(GradientBoostingClassifier())
yprob=cross_val_predict(clf, X, y, method='predict_proba')
print(yprob[:5, :])
gives this error
Traceback (most recent call last):
File "example.py", line 17, in <module>
yprob = cross_val_predict(clf, X, y, method = 'predict_proba')
File "/usr/local/lib/python3.7/site-packages/sklearn/model_selection/_validation.py", line 723, in cross_val_predict
y = le.fit_transform(y)
File "/usr/local/lib/python3.7/site-packages/sklearn/preprocessing/label.py", line 235, in fit_transform
y = column_or_1d(y, warn=True)
File "/usr/local/lib/python3.7/site-packages/sklearn/utils/validation.py", line 783, in column_or_1d
raise ValueError("bad input shape {0}".format(shape))
ValueError: bad input shape (1000, 5)
I think cross_val_predict should probably not throw the ValueError: bad input shape if y is 2D and the estimator is a OneVsRestClassifer.
Activity
agramfort commentedon May 3, 2018
please fill up the section: Steps/Code to Reproduce
thanks
princejha95 commentedon May 3, 2018
Can I work on this issue if no one is assigned to it ?
vivek531 commentedon May 3, 2018
Added Steps/Code to Reproduce
jaebird123 commentedon Oct 9, 2018
I have a similar issue with the
predict_probamethod. Running the followinggives this error
I think
cross_val_predictshould probably not throw theValueError: bad input shapeifyis 2D and the estimator is aOneVsRestClassifer.amueller commentedon Oct 9, 2018
this is fixed by #8773 (which is not merged yet) right?