天天看點

python如何傳回二項式的值,嶺二項式回歸在Python中可用嗎?

python如何傳回二項式的值,嶺二項式回歸在Python中可用嗎?

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.

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?

解決方案

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

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.