Calling goodness of fit value with result.prsquared() in statsmodels results TypeError: 'numpy.float64' object is not callable

Calling goodness of fit value with result.prsquared() in statsmodels results TypeError: 'numpy.float64' object is not callable

我是一个完全的初学者,我目前正在使用 python 3.4 中的 statsmodels 0.6.1 和 Pycharm 社区版本 4.5.1 进行有关 logit 回归模型的教程:

http://blog.yhathq.com/posts/logistic-regression-and-python.html

运行顺利。我尝试添加自己的台词,尝试一些东西。

在我拟合数据的部分之后

train_cols = data.columns[1:]
logit = sm.logit(data['admit'], data[train_cols])
result = logit.fit()

然后我打印出摘要

print(result.summary())

我试图绕过教程,只打印拟合优度测量值(在本例中,它是一个伪 R 平方值)。根据 documentation 它是结果对象的一种方法(与摘要相同),因此它应该像这样工作:

print(result.prsquared())

但是,运行 此代码会在仅包含 print(result.prsquared()):

的行上导致 TypeError

TypeError: 'numpy.float64' object is not callable

这真的让我很烦恼,因为如果我要比较几个模型,伪 R 平方将是我的首选。

prsquared 是一个 属性 ,不是函数。尝试:

print(result.prsquared)