-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
LogisticRegressionCV fails when labels are strings #5868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think the error is in old version. I successfully recreated the error with the old version of scikit I had, I then updated it and I am not getting the error anymore, thoughts? |
I also confirm that it is no longer a problem @ master... @GaelVaroquaux can be closed... |
setting multi_class='multinomial' it fails also on master for me. Check the following example from sklearn.linear_model import LogisticRegressionCV
import numpy as np
n_samples, n_features = 50, 5
rng = np.random.RandomState(0)
X_ref = rng.randn(n_samples, n_features)
y = rng.choice(['foo', 'bar', 'baz'], n_samples)
X_ref -= X_ref.mean()
X_ref /= X_ref.std()
lr_cv = LogisticRegressionCV(Cs=[1.], fit_intercept=False, multi_class='multinomial')
lr_cv.fit(X_ref, y) |
Ermm... sorry for suggesting to close this issue... the label encoder was not properly used... fix at #5874 |
While LogisticRegression can handle string labels, LogisticRegressionCV fails when labels are strings with
ValueError: could not convert string to float
I guess the problem comes from calling
y_test = check_array(y_test, dtype=np.float64, ensure_2d=False)
within function _log_reg_scoring_path in file logistic.py
The text was updated successfully, but these errors were encountered: