Python Logistic 回归优势比 0 或 1

发布于 2025-01-09 20:56:30 字数 3635 浏览 1 评论 0原文

编辑: 对于哪个类别,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.4970352.6700682.582102
x11.1109171.1965091.152919
x21.1853601.2726261.228218
x32.4245282.7529942.583546
x41.0677061.1357631.101209
x51.2597651.3483881.303323
x67.1041227.5636647.330293

反之亦然,0=是, 1=否

5%95%比值
比常量0.3768130.4028340.389606
x10.8289150.8926280.860182
x20.7829830.8404190.811193
x30.3740060.4240370.398237
x40.8724280.9279730.899772
x50.7395070.7913520.764990
x67.0961977.5544047.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
const2.4970352.6700682.582102
x11.1109171.1965091.152919
x21.1853601.2726261.228218
x32.4245282.7529942.583546
x41.0677061.1357631.101209
x51.2597651.3483881.303323
x67.1041227.5636647.330293

And the other way around, 0=yes, 1=no

5%95%Odds Ratio
const0.3768130.4028340.389606
x10.8289150.8926280.860182
x20.7829830.8404190.811193
x30.3740060.4240370.398237
x40.8724280.9279730.899772
x50.7395070.7913520.764990
x67.0961977.5544047.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

标点 2025-01-16 20:56:30

我想我终于找到了答案:

“由于 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."

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文