Last Updated on 2021-10-30 by Clay
完整的報錯訊息為:
Start to train the model.
\sklearn\linear_model\_logistic.py:763: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.
Increase the number of iterations (max_iter) or scale the data as shown in:
https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression n_iter_i = _check_optimize_result(
\sklearn\linear_model\_logistic.py:763: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.
Increase the number of iterations (max_iter) or scale the data as shown in:
https://scikit-learn.org/stable/modules/preprocessing.html
Please also refer to the documentation for alternative solver options:
https://scikit-learn.org/stable/modules/linear_model.html#logistic-regression n_iter_i = _check_optimize_result(
這個錯誤訊息的意思是 lbfgs 無法收斂,因為迭代次數達到上限而中止。
解決方法
解決方法不外乎三種:
- 增加迭代總數(max_iter 參數預設為 100)
- 縮放資料規模(scale)
- 更換其他求解器(solver)
References
- https://stackoverflow.com/questions/62658215/convergencewarning-lbfgs-failed-to-converge-status-1-stop-total-no-of-iter
- https://stats.stackexchange.com/questions/184017/how-to-fix-non-convergence-in-logisticregressioncv
- https://github.com/scikit-learn/scikit-learn/issues/10866