Is ridge binomial regression available in Python?

心已入冬 提交于 2019-12-10 12:23:35

问题


I am new to Python and I would like to fit a ridge binomial regression. I know that binomial regression is available at: http://statsmodels.sourceforge.net/devel/glm.html

I also know that logistic regression with L2 penalty can be fitted with sklearn.linear_model.

http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html

As binomial is sum of Bernoulli, I could use scikit after transforming my binomial structured data into Bernoulli structure, by changing its i^th row:

(size_i, success_i)

into a vector of length size_i recording success_i 1 and size_i - success_i 0. However, this does not work for me as size_i is very large.

Is there way to fit Binomial ridge regression using Python?


回答1:


statsmodels GLM does not have full penalization support yet, however it has now elastic net L1/L2 penalization in master. It is not yet included in the online documentation

https://github.com/statsmodels/statsmodels/blob/master/statsmodels/genmod/generalized_linear_model.py#L1007

GLM(...).fit_regularized(alpha=..., L1_wt=0) would fit just a L2 Ridge penality.

Warning: Because this is a feature that has just been merged and has not seen heavy usage yet, it is still considered experimental. It should produce the correct results but API and implementation will most likely still change.



来源:https://stackoverflow.com/questions/36441450/is-ridge-binomial-regression-available-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!