# Possible to evaluate GLM in Python/scikit-learn using the Poisson, Gamma, or Tweedie distributions as the family for the error distribution?

Trying to learn some Python and Sklearn, but for my work I need to run regressions that use error distributions from the Poisson, Gamma, and especially Tweedie families.

I don't see anything in the documentation about them, but they are in several parts of the R distribution, so I was wondering if anyone has seen implementations anywhere for Python. It would be extra cool if you can point me towards SGD implementations of the Tweedie distribution!

• The most robust GLM implementations in Python are in [statsmodels]statsmodels.sourceforge.net, though I'm not sure if there are SGD implementations.
– Trey
May 31, 2014 at 14:10
• Thanks Trey. It looks like there's no support for Tweedie, but they do have some discussion of Poisson and Gamma distributions.
– joe
May 31, 2014 at 21:33

Update (Jan 2023) - sklearn has Tweedie, Poisson, and gamma GLMs as of v 0.23 in May 2020.

There is movement to implement generalized linear models with Poisson, gamma, and Tweedie error distributions in scikit-learn.

Statsmodels has implementations of generalized linear models with Poisson, Tweedie, and gamma error distributions.

While I'm updating this answer, Spark ML also (experimentally) supports Poisson, Tweedie, and gamma distributions.

• I'm working on it: github.com/madrury/py-glm Sep 1, 2017 at 13:47
• @MatthewDrury Awesome!
– Neal
Sep 1, 2017 at 13:54
• @MatthewDrury nice! I just started using GLM's, and statsmodels has some limitations. Not sure I understand the math fully, but could your inner-solve be replaced with an arbitrary least-squares-type solver? I was thinking this would add flexibility (e.g. pass in sklearn.ElasticNet to get scalability/regularization/etc. "for free"?). Jul 18, 2018 at 2:13

H2O has Generalized Linear Models.

They use H2O Frames though, so you can't use Pandas/Numpy directly.