0
votes

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

1 Answers

2
votes

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.