Skip to content

Instantly share code, notes, and snippets.

@glamp
Last active December 25, 2018 03:25
Show Gist options
  • Save glamp/5074027 to your computer and use it in GitHub Desktop.
Save glamp/5074027 to your computer and use it in GitHub Desktop.
train_cols = data.columns[1:]
# Index([gre, gpa, prestige_2, prestige_3, prestige_4], dtype=object)
logit = sm.Logit(data['admit'], data[train_cols])
# fit the model
result = logit.fit()
@hsimpson22
Copy link

I think the Index comment here is wrong, it should include the Intercept column also, right? That really confused me at first! I thought you were creating the intercept column but then not actually using it in the model.

And thanks for the tutorial! It helped me out a lot, other than that one confusing part :)

@s0k-IT
Copy link

s0k-IT commented Oct 31, 2015

Any Idea why I am getting this error when running this logit code?

logit = sm.Logit(data['admit'], data[train_cols])
AttributeError: 'module' object has no attribute 'Logit'

I have been reading the documentation, and have read about endog, and exog. Have the format for the parameters changed or something? I can not seem to figure it out any ideas would be appreciated it!

@s0k-IT
Copy link

s0k-IT commented Oct 31, 2015

Never mind,
found my problem
import statsmodels
instead of:
import statsmodels.api as sm

@vickytilotia
Copy link

yeah!!!
use
import statsmodels as sm
instead of
import statsmodels.api as sm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment