【发布时间】:2020-09-25 06:32:44
【问题描述】:
我正在训练一个数字数据集,以使用逻辑回归多类分类对数字进行分类。通过使用此代码
from sklearn.datasets import load_digits
%matplotlib inline
import matplotlib.pyplot as plt
digits = load_digits()
plt.gray()
for i in range(5):
plt.matshow(digits.images[i])
from sklearn.linear_model import LogisticRegression
model = LogisticRegression()
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(digits.data,digits.target, test_size=0.2)
model.fit(X_train, y_train)
当我执行单元格时,我正在 jupyter notebook 中执行此操作
model.fit(X_train, y_train)
我收到类似警告
C:\Users\Shubham Teke\anaconda3\envs\allenv\lib\site-packages\sklearn\linear_model\_logistic.py:764: 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)
LogisticRegression()
那么这个警告是什么以及如何解决这个问题?
【问题讨论】:
标签: python data-science logistic-regression