Issue
I have been using a course on Udemy for learning Machine-Learning. I have found a lot of deprecated code and now I have this issue:
The code:
from sklearn.linear_model import LogisticRegression
classifier = LogisticRegression(random_state = 0)
classifier.fit(X_train, y_train)
The warning:
C:\Users\admin\Anaconda3\lib\site-packages\sklearn\linear_model\logistic.py:432: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning.
FutureWarning)
How can I get rid of this deprecation warning?
Solution
In scikit-learn v0.20, which you probably use, the default value for the solver
used in LogisticRegression
was liblinear
; from the docs:
solver : str, {‘newton-cg’, ‘lbfgs’, ‘liblinear’, ‘sag’, ‘saga’}, default: ‘liblinear’.
This changed in v0.22 (current latest) to lbfgs
.
So, in order to avoid surprizes from this change, scikit-learn warns you for this change in the default that will come in future versions, in order to keep your code future-proof.
To get rid of it, just define explicitly a solver in your LogisticRegression
definition, i.e.
classifier = LogisticRegression(random_state = 0, solver='lbfgs') # default in v0.22
or
classifier = LogisticRegression(random_state = 0, solver='liblinear') # default until v0.21
The first documentation link provided above shows all the available options, along with some short comment/advice on each one.
Answered By - desertnaut
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.