question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: LogisticRegression `fit()` method broken with default solver( lbfgs ) for scikit-learn 0.23.2

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
NicolasHugcommented, Mar 31, 2021

Looks like the issue was introduced in scipy>=1.6.0, which was released after scikit-learn 0.23.2. Any chance you can downgrade scipy instead of upgrading scikit-learn?

0reactions
NicolasHugcommented, Apr 1, 2021

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).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found