Search code examples
pythonpandasleast-squares

'OLS' object has no attribute 'summary'


I'm posting this question for those who ran into the same issue I ran into:

When trying to fit my data like so, and printing the result:

import statsmodel.api as sm
model = sm.OLS(df['SalePrice'], df.drop(['SalePrice'], axis=1))
print(model.summary())

I get the following error:

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

Solution

  • The solution was to add .fit():

    import statsmodel.api as sm
    model = sm.OLS(df['SalePrice'], df.drop(['SalePrice'], axis=1)).fit()
    print(model.summary())