2 回答
TA贡献1871条经验 获得超8个赞
如果您想忽略它,请将以下内容添加到顶部的代码中:
import warnings
warnings.filterwarnings("ignore", category=FutureWarning)
否则指定求解器如下:
LogisticRegression(solver='lbfgs')
solver : str, {‘newton-cg’, ‘lbfgs’, ‘liblinear’, ‘sag’, ‘saga’}, default: ‘liblinear’.
Algorithm to use in the optimization problem.
For small datasets, ‘liblinear’ is a good choice, whereas ‘sag’ and ‘saga’ are faster for large ones.
For multiclass problems, only ‘newton-cg’, ‘sag’, ‘saga’ and ‘lbfgs’ handle multinomial loss; ‘liblinear’ is limited to one-versus-rest schemes.
‘newton-cg’, ‘lbfgs’ and ‘sag’ only handle L2 penalty, whereas ‘liblinear’ and ‘saga’ handle L1 penalty.
TA贡献1824条经验 获得超8个赞
如果您使用的逻辑回归模型将惩罚='l1' 作为超参数,您可以使用 solver='liblinear'
我的代码示例::
logistic_regression_model=LogisticRegression(penalty='l1',dual=False,max_iter=110, solver='liblinear')
添加回答
举报