1. Sklearn
1.1. lbfgs failed to converge (status=1)
/Users/r123m/opt/anaconda3/envs/myenv/lib/python3.6/site-packages/sklearn/linear_model/_logistic.py:765: 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
extra_warning_msg=_LOGISTIC_SOLVER_CONVERGENCE_MSG)
解决方法:
# 指定最大迭代次数
LR = LogisticRegression(max_iter=10000)
2. Numpy
2.1 invalid value encountered in sqrt
sqrt中出现了负数。如果只是个别个,那么就选择忽略。
np.seterr(invalid='ignore')