Python ';OLS&x27;对象没有属性';总结';

Python ';OLS&x27;对象没有属性';总结';,python,pandas,least-squares,Python,Pandas,Least Squares,我为那些遇到我遇到的同一问题的人发布这个问题: 尝试这样拟合数据并打印结果时: 将statsmodel.api导入为sm model=sm.OLS(df['SalePrice'],df.drop(['SalePrice'],axis=1)) 打印(model.summary()) 我得到以下错误: AttributeError: 'OLS' object has no attribute 'summary' 解决方案是添加.fit(): 将statsmodel.api导入为sm model=

我为那些遇到我遇到的同一问题的人发布这个问题:

尝试这样拟合数据并打印结果时:

将statsmodel.api导入为sm
model=sm.OLS(df['SalePrice'],df.drop(['SalePrice'],axis=1))
打印(model.summary())
我得到以下错误:

AttributeError: 'OLS' object has no attribute 'summary'

解决方案是添加
.fit()

将statsmodel.api导入为sm
model=sm.OLS(df['SalePrice'],df.drop(['SalePrice'],axis=1)).fit()
打印(model.summary())