Reputation: 425
I am new to Python and I am trying to build a simple linear regression model. I am able to build the model and see the results, but when I try to look at the parameters I get an error and I am not sure where I am going wrong.
Code:
import statsmodels.formula.api as smf
from sklearn.linear_model import LinearRegression
lm = LinearRegression()
lm = smf.ols(formula='medv ~ lstat', data=data).fit()
lm.describe
produces results
Dep. Variable: medv R-squared: 0.544
Model: OLS Adj. R-squared: 0.543
Method: Least Squares F-statistic: 601.6
Date: Wed, 06 May 2015 Prob (F-statistic): 5.08e-88
Time: 15:01:03 Log-Likelihood: -1641.5
No. Observations: 506 AIC: 3287.
Df Residuals: 504 BIC: 3295.
Df Model: 1
But when I try to call the parameters
lm.params()
I receive this
Series object is not callable
I must be missing something but I am not sure what it is. The model is being produced correctly. Thanks!
Upvotes: 0
Views: 2292
Reputation: 1967
Try
lm.params
instead of
lm.params()
The latter tries to call the params as a function (which it isn't)
Upvotes: 1