AttributeError: LogisticRegression `fit()` method broken with default solver( lbfgs ) for scikit-learn 0.23.2
See original GitHub issueDescribe the bug
In scikit-learn 0.23.2, LogisticRegression fit()
method broken with default solver ( lbfgs )
Steps/Code to Reproduce
Log information :
Python 3.7.10 (default, Mar 1 2021, 12:53:44)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sklearn.datasets import load_iris
>>> from sklearn.linear_model import LogisticRegression
>>> X, y = load_iris(return_X_y=True)
>>> clf = LogisticRegression(random_state=0).fit(X, y)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/miniconda3/envs/sklearn_test/lib/python3.7/site-packages/sklearn/linear_model/_logistic.py", line 1417, in fit
for class_, warm_start_coef_ in zip(classes_, warm_start_coef))
File "/opt/miniconda3/envs/sklearn_test/lib/python3.7/site-packages/joblib/parallel.py", line 1041, in __call__
if self.dispatch_one_batch(iterator):
File "/opt/miniconda3/envs/sklearn_test/lib/python3.7/site-packages/joblib/parallel.py", line 859, in dispatch_one_batch
self._dispatch(tasks)
File "/opt/miniconda3/envs/sklearn_test/lib/python3.7/site-packages/joblib/parallel.py", line 777, in _dispatch
job = self._backend.apply_async(batch, callback=cb)
File "/opt/miniconda3/envs/sklearn_test/lib/python3.7/site-packages/joblib/_parallel_backends.py", line 208, in apply_async
result = ImmediateResult(func)
File "/opt/miniconda3/envs/sklearn_test/lib/python3.7/site-packages/joblib/_parallel_backends.py", line 572, in __init__
self.results = batch()
File "/opt/miniconda3/envs/sklearn_test/lib/python3.7/site-packages/joblib/parallel.py", line 263, in __call__
for func, args, kwargs in self.items]
File "/opt/miniconda3/envs/sklearn_test/lib/python3.7/site-packages/joblib/parallel.py", line 263, in <listcomp>
for func, args, kwargs in self.items]
File "/opt/miniconda3/envs/sklearn_test/lib/python3.7/site-packages/sklearn/linear_model/_logistic.py", line 764, in _logistic_regression_path
extra_warning_msg=_LOGISTIC_SOLVER_CONVERGENCE_MSG)
File "/opt/miniconda3/envs/sklearn_test/lib/python3.7/site-packages/sklearn/utils/optimize.py", line 243, in _check_optimize_result
).format(solver, result.status, result.message.decode("latin1"))
AttributeError: 'str' object has no attribute 'decode'
>>>
Package versions:
python 3.7.10
scikit-learn 0.23.2
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
How to Fix FutureWarning Messages in scikit-learn
FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning. This issue involves a change from ......
Read more >sklearn.linear_model.LogisticRegression
This class implements regularized logistic regression using the 'liblinear' library, 'newton-cg', 'sag', 'saga' and 'lbfgs' solvers. Note that regularization is ...
Read more >AttributeError: 'str' object has no attribute 'decode' in fitting ...
I tried to upgrade my scikit-learn using the below command, still, that didn't solve the AttributeError: 'str' object has no attribute ...
Read more >Logistic Regression using Python (scikit-learn)
While this tutorial uses a classifier called Logistic Regression, the coding process in this tutorial applies to other classifiers in sklearn (Decision Tree ......
Read more >scikit-learn user guide
scikit-learn, that is a fit, predict/transform interface and ordinarily having ... You can find more default on the new start methods in the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks like the issue was introduced in
scipy>=1.6.0
, which was released afterscikit-learn 0.23.2
. Any chance you can downgrade scipy instead of upgrading scikit-learn?I was thinking the same, although it’s possible that
a) scipy broke backward compat but they issued a deprecation warning that we ignored b) we had been relying on a “private” thing (or something with no backward-compat guanrantee)
in which case an upper bound would not have helped (but IDK if any of these apply here).