简体   繁体   English

逻辑回归和 sklearn 的问题

[英]Problem with Logistic Regression and sklearn

I need to do Logistic Regression using Python, but I have constantly comunicate as below when I try to apply the logistic regression.我需要使用 Python 进行逻辑回归,但是当我尝试应用逻辑回归时,我经常如下沟通。 Please help me, what should I do?请帮帮我,我该怎么办? I can add that I have already installed sklearn.我可以补充一点,我已经安装了 sklearn。

C:\Users\John12\Anaconda3\lib\site-packages\sklearn\linear_model\logistic.py:432: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. C:\Users\John12\Anaconda3\lib\site-packages\sklearn\linear_model\logistic.py:432:FutureWarning:默认求解器将在 0.22 中更改为“lbfgs”。 Specify a solver to silence this warning.指定求解器以消除此警告。 FutureWarning)未来警告)

Go to where you implement your LR and make sure you add the following. Go 到您实现 LR 的位置,并确保添加以下内容。 Please provide code next time下次请提供代码

# create and configure model
model = LogisticRegression(solver='lbfgs')

This is not an error, this is a warning.这不是错误,这是警告。 There is a good post about it: How do I solve the future warning -> % (min_groups, self.n_splits)), Warning) in python?有一篇关于它的好帖子: How do I solve the future warning -> % (min_groups, self.n_splits)), Warning) in python? . .

Your warning means that the default solver will change in another version of your library.您的警告意味着默认求解器将在您的库的另一个版本中更改。

One way is to ignore the warning (not recommended):一种方法是忽略警告(不推荐):

import warnings
warnings.filterwarnings("ignore", category=FutureWarning)

And the other one is to specifiy your solver:另一个是指定你的求解器:

model = LogisticRegression(solver='lbfgs')

When you specified your solver, you will not have the problem that the defaul solver (when you don't specifiy anything) will be changed in the next version...当您指定求解器时,您将不会遇到默认求解器(当您不指定任何内容时)将在下一个版本中更改的问题......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM