-
-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Description
- StackOverflow Question: https://stackoverflow.com/questions/42151921/array-like-input-for-sklearn-logisticregressioncv/42152550#42152550
Description
TypeError: Expected sequence or array-like, got estimator
Steps/Code to Reproduce
Example:
import numpy as np
from sklearn.metrics import accuracy_score
from sklearn.linear_model import LogisticRegressionCV
X=np.random.rand(50,5)
y=np.random.randint(2, size=50)
logmodel = LogisticRegressionCV(Cs =1, dual=False , scoring = accuracy_score, penalty = 'l2')
logmodel.fit(X, y)
Expected Results
No error is thrown.
Actual Results
TypeError: Expected sequence or array-like, got estimator
Observation:
Passing 'accuracy' or make_scorer(accuracy_score) works correctly. If this is the intended behaviour it should be mentioned in documentation.
Documentation says "Scoring function to use as cross-validation criteria. For a list of scoring functions that can be used, look at sklearn.metrics. The default scoring option used is accuracy_score.". So user may be tempted to pass accuracy_score as argument which throws the error.
Suggestion
If it is the intended behaviour, then please make the documentation same as GridSearchCV, so that the confusion may be avoided
"A string (see model evaluation documentation) or a scorer callable object / function with signature scorer(estimator, X, y). If None, the score method of the estimator is used"
Versions
Linux-3.16.0-77-generic-x86_64-with-Ubuntu-14.04-trusty
('Python', '2.7.6 (default, Oct 26 2016, 20:30:19) \n[GCC 4.8.4]')
('NumPy', '1.12.0')
('SciPy', '0.18.1')
('Scikit-Learn', '0.18.1')