Python Logistic 回归优势比 0 或 1
编辑: 对于哪个类别,Python sklearn Logistic 回归默认为 0 或 1 提供系数,从而提供优势比。
我想知道我在逻辑回归中得到哪个类别的优势比:
优势比:
params = model.params
conf = model.conf_int()
conf['Odds Ratio'] = params
conf.columns = ['5%', '95%', 'Odds Ratio']
print(np.exp(conf))
所以首先如果 1 = 是并且 0 = 否,那么:
5% | 95% | 比值比 | |
---|---|---|---|
常数 | 2.497035 | 2.670068 | 2.582102 |
x1 | 1.110917 | 1.196509 | 1.152919 |
x2 | 1.185360 | 1.272626 | 1.228218 |
x3 | 2.424528 | 2.752994 | 2.583546 |
x4 | 1.067706 | 1.135763 | 1.101209 |
x5 | 1.259765 | 1.348388 | 1.303323 |
x6 | 7.104122 | 7.563664 | 7.330293 |
反之亦然,0=是, 1=否
5% | 95% | 比值 | |
---|---|---|---|
比常量 | 0.376813 | 0.402834 | 0.389606 |
x1 | 0.828915 | 0.892628 | 0.860182 |
x2 | 0.782983 | 0.840419 | 0.811193 |
x3 | 0.374006 | 0.424037 | 0.398237 |
x4 | 0.872428 | 0.927973 | 0.899772 |
x5 | 0.739507 | 0.791352 | 0.764990 |
x6 | 7.096197 | 7.554404 | 7.321717 |
我认为赔率是 =1,但是根据数据的一些自然假设,至少有一个 Yes = 1 的赔率对我来说没有意义,并且所有低于 Yes = 0 的赔率比(除了上面没有意义的赔率)也没有什么意义。基于我对数据的假设的感觉;但无论如何我想对此事进行一些确认。
Edit:
For which category, 0 or 1 does Python sklearn Logistic Regression by default provides the coefficient and thus the Odds Ratio.
I'm wondering for which category I'm getting my odds ratio in a logistic regression:
Odds ratio:
params = model.params
conf = model.conf_int()
conf['Odds Ratio'] = params
conf.columns = ['5%', '95%', 'Odds Ratio']
print(np.exp(conf))
So first of if 1 = Yes and 0 = No then:
5% | 95% | Odds Ratio | |
---|---|---|---|
const | 2.497035 | 2.670068 | 2.582102 |
x1 | 1.110917 | 1.196509 | 1.152919 |
x2 | 1.185360 | 1.272626 | 1.228218 |
x3 | 2.424528 | 2.752994 | 2.583546 |
x4 | 1.067706 | 1.135763 | 1.101209 |
x5 | 1.259765 | 1.348388 | 1.303323 |
x6 | 7.104122 | 7.563664 | 7.330293 |
And the other way around, 0=yes, 1=no
5% | 95% | Odds Ratio | |
---|---|---|---|
const | 0.376813 | 0.402834 | 0.389606 |
x1 | 0.828915 | 0.892628 | 0.860182 |
x2 | 0.782983 | 0.840419 | 0.811193 |
x3 | 0.374006 | 0.424037 | 0.398237 |
x4 | 0.872428 | 0.927973 | 0.899772 |
x5 | 0.739507 | 0.791352 | 0.764990 |
x6 | 7.096197 | 7.554404 | 7.321717 |
I'm thinking the odds are for =1, however at least one of the odds where Yes = 1 is not making sense to me based on some natural assumptions of the data, and all the odds ratios below where yes = 0, except the one that doesn't make sense above, also make little sense based on my assumptions of the data; but anyway I'd like some confirmation on the matter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我终于找到了答案:
“由于 logit 函数,逻辑回归系数表示在给定 X 变量值的情况下,观测值属于目标类 (“1”) 的对数几率。”
I think I finally found my answer:
"Because of the logit function, logistic regression coefficients represent the log odds that an observation is in the target class (“1”) given the values of its X variables."