简体   繁体   中英

How to use lasso/ridge regression model in statsmodels?

I would like to use lasso or ridge regression in my model to handle multicolinearity, but when I try to do so and to watch the summary, i get an error:

print(lasso_r.summary())
  File "C:\Users\aleks\PycharmProjects\statistics\venv\lib\site-packages\statsmodels\base\model.py", line 1177, in summary
    raise NotImplementedError
NotImplementedError

My code looks the next way:

lr = sm.OLS.from_formula("Ozone~Q('Solar.R')+Wind+Temp",data=air)
lasso_r = lr.fit_regularized(method='sqrt_lasso')
print(lasso_r.summary())

Could you tell me, please, what could cause this problem and how i can fix it?

The method summary simply isn't implemented yet for lasso and ridge regression and in general any model from lr.fit_regularized , hence the error NotImplementedError

summary is only available for a normal OLS ie normal_ols = lr.fit()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM