Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

statsmodel AttributeError: module 'scipy.stats' has no attribute 'chisqprob'

I'm running the code below with statsmodel 0.8.0 which i believe is the latest.

import statsmodels.api as sm
est = sm.Logit(y_train, x_train)
result = est.fit()
print(result.summary())

This is giving me an error saying:

AttributeError: module 'scipy.stats' has no attribute 'chisqprob'.

I dont seem to be able to find anything on stackoverflow or elsewhere to resolve this. Any help much appreciated.

like image 335
A Rob4 Avatar asked Apr 13 '18 09:04

A Rob4


3 Answers

Try this:

result.summary2()

Link:

http://www.statsmodels.org/stable/generated/statsmodels.discrete.discrete_model.LogitResults.summary2.html?highlight=summary2#statsmodels.discrete.discrete_model.LogitResults.summary2

like image 144
CapAllen Avatar answered Nov 03 '22 04:11

CapAllen


You have two options. Either use,

> result.summary2()

or you can import chisqprob.

> from scipy import stats

> stats.chisqprob = lambda chisq, df: stats.chi2.sf(chisq, df)
like image 38
Jiaqiang Yi Avatar answered Nov 03 '22 06:11

Jiaqiang Yi


I had the same problem but this solved it. However, you first need to import stats from scipy.

stats.chisqprob = lambda chisq, df: stats.chi2.sf(chisq, df)

Hope it helps you.

like image 2
Kaimenyi Avatar answered Nov 03 '22 05:11

Kaimenyi