Investigate a ConvergenceWarning instead of hiding it
By Gistmax Tutorials · 2026-11-04
A linear classifier finishes with a ConvergenceWarning. Suppressing the warning removes the message but does not establish that the optimisation reached a satisfactory solution.
Why this happens
Poor feature scaling, an unsuitable solver, difficult data or an insufficient iteration budget can prevent convergence. Increasing iterations is useful only when it addresses the actual issue.
Step-by-step solution
1. Check feature ranges, missing values and outliers. Scale suitable numeric features within a pipeline.
2. Confirm the solver and penalty combination is supported for the estimator. Start with a sensible baseline configuration.
3. Increase the iteration budget if the optimisation is progressing, then inspect whether the warning disappears and validation behaviour remains stable.
Worked example
For LogisticRegression, compare a scaled pipeline with the unscaled version before making max_iter extremely large. Keep the same split and scoring method so the comparison remains meaningful.
Verify the fix
A clean run should be accompanied by stable validation results and reasonable runtime. Test repeatability; absence of a warning is not proof that the model is useful.
Prevent a repeat
Capture warnings in experiment logs and review them during model release. Avoid global warning suppression that hides unrelated numerical problems.
Reference
Official documentation or standards guidance
An original Gistmax troubleshooting guide. Scenarios and sample values are illustrative; configuration depends on your software version and environment. Cover diagram: Gistmax Tutorials.