EasyDeepLearn

Your scikit-learn logistic regression warns 'lbfgs failed to converge'. What do you do?

medium

Answer

  • Common fixes: (1) standardize features — most convergence issues come from ill-scaled features; (2) increase maxiter\operatorname{max}_{\mathrm{iter}} (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 maxiter\operatorname{max}_{\mathrm{iter}}, add regularization, or switch solver
  • Change the metric to accuracy
  • Drop the training set

Non-convergence is usually about scale  /  maxiter  /  regularization  /  separation\mathrm{scale}\; / \;\operatorname{max}_{\mathrm{iter}}\; / \;\mathrm{regularization}\; / \;\mathrm{separation}.

#logistic-regression#optimization#preprocessing

Practise Supervised Learning

215 interview questions in this topic.

Related questions