ConvergenceWarning with GridSearchCV and LinearSVC #23335
yangfan0356
started this conversation in
General
Replies: 1 comment 1 reply
-
You could increase the number of iterations and make sure that the model is converging. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
We tried to use GridSearchCV to search the best parameter, e.g, C value for LinearSVC.
We noticed that for certain C values (Note we have already changed the max_iter parameter of LinearSVC to quite large), we will get this warning:
ConvergenceWarning: Liblinear failed to converge, increasing the number of iterations.
The problem is: if we specify several C values in an array e.g, [0.01,10], with the following example scores.
parameter: {'C': 0.001} -------- without converge warning
best score: 0.6852380952380952
parameter: {'C': 10} ---------- with converge warning
best score: 0.7017460317460317
The GridSearchCV will pick the C value with 10 (which has the best score) to be the best estimator, even though there is converge warning message. And according to this post, when a model with ConvergenceWarning, it will not be reliable
https://stackoverflow.com/questions/52670012/convergencewarning-liblinear-failed-to-converge-increase-the-number-of-iterati
How shall we only select a best estimator without any ConvergenceWarning using GridSearchCV. Or do you have other best practice to select C?
Fan
Beta Was this translation helpful? Give feedback.
All reactions