Your scikit-learn logistic regression warns 'lbfgs failed to converge'. What do you do?
mediumAnswer
- Common fixes: (1) standardize features — most convergence issues come from ill-scaled features; (2) increase (e.g., 1000); (3) increase regularization C down (stronger penalty smooths the loss); (4) switch solver ('saga' or 'liblinear' for L1, 'newton-cg' for very small data); (5) check for perfect / near-perfect separation and add L2 or drop the offending feature; (6) verify the target is not constant.
Check yourself — multiple choice
- Remove the intercept
- Standardize features, increase , add regularization, or switch solver
- Change the metric to accuracy
- Drop the training set
Non-convergence is usually about .
#logistic-regression#optimization#preprocessing
Practise Supervised Learning
215 interview questions in this topic.
Related questions
- Why do we use cross-entropy (log loss) instead of MSE for classification?
- How is logistic regression fit in practice?
- Which models need feature scaling and which don't?
- What is Empirical Risk Minimization?
- Why do we care whether the loss landscape is convex?
- Why does OLS have a closed-form solution but logistic regression doesn't?