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.
CodePudding user response:
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."