0

I am trying to run the scikit-learn tool GridSearchCV, but the following code

from sklearn.ensemble import AdaBoostRegressor
from sklearn.datasets import make_regression
from sklearn.model_selection import GridSearchCV 

X, y = make_regression(
    n_features=5, n_informative=3, n_samples=200)

params = {'n_estimators': range(1, 100),
          'learning_rate': [.01, .1, .2, .5, .7, .9, .99, 1]}

optRegressor = GridSearchCV(
    AdaBoostRegressor(), params,
    scoring = 'accuracy', cv = 5, n_jobs = -1, verbose=3)

optRegressor.fit(X, y)

returns

ValueError: continuous is not supported

This question has a similar problem, but the answer is to convert pandas dataframes to numpy arrays. I am already using numpy arrays, so this does not apply.

The problem in this other question is linked to the score used. But the documentation states, regarding the scoring parameter that

If None, the estimator’s score method is used.

So the scoring method used should be, by default in this case, the AdaBoostRegressor.score. This scoring method is obviously a regression score, so that solution doesn't work either.


How can I run the GridSearchCV on this example?

usernumber
  • 1,958
  • 1
  • 21
  • 58
  • 2
    But you are using `scoring = 'accuracy'`, not `None`, so you are overiding the default value with an inappropriate score function, hence the error. – desertnaut May 04 '20 at 19:17
  • As is, the issue is due to the inappropriate `scoring = 'accuracy'` function used, and the question is a duplicate of the second linked thread. – desertnaut May 05 '20 at 00:04

0 Answers0