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

machine-learning, python, python-2.7, scikit-learn

Solution

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.

Problem

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

Original source