Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GridSearchCV and LogisticRegression raise ValueError: Can't handle mix of continuous and binary

I'm trying to run gridsearch with LogisticRegression, and get

ValueError: Can't handle mix of continuous and binary

I've traced this error to metrics.accuracy_score. Apparently the prediction doesn't go so well, and while the y_true is continuous (as is the rest of the data), y_pred is all zeros and is thus classified as binary.

  • Is there any way to avoid this error?
  • Does the nature of y_pred means I have no business using logistic regression at all, or could this be a result of the parameters used?

Thanks

like image 775
Korem Avatar asked Jun 05 '14 13:06

Korem


1 Answers

Somewhat confusingly logistic regression is actually a classification algorithm (see http://scikit-learn.org/stable/modules/linear_model.html#logistic-regression). As such the target ("y_true") data that you feed it should be binary. If you are actually trying to solve a regression problem you should choose a different algorithm, e.g. LinearRegression, SVR, RandomForestRegressor, etc.

like image 79
DavidS Avatar answered Oct 05 '22 19:10

DavidS