# Is TweedieRegressor a completely general GLM solution?

I consider sklearn's TweedieRegressor a general solution for all types of regression, as it is a GLM model. If I understand well, that means any regression type can be obtained by appropriately parametrizing TweedieRegressor.

Logistic regression is a special case of GLM. I guess, to have logistic regression there should be a logit value (or something like that) for the link parameter, but there is no such possibility.

Can TweedieRegressor be parametrized to do logistic regression?
If yes, how? If not, why not?

• Your presumption about "all types of regression" is incorrect: this software can only model a limited (but still large) number of response distributions. Among the common ones not included are Binomial, Multinomial, and Negative Binomial. That's why sklearn offers a separate function for those distributions! – whuber Feb 26 at 20:00
• It might be worth noting that under the hood, sklearn uses the GeneralizedLinearModel class to do most of the heavy lifting, and TweedieRegressor does very little else, so aside from the modules not being public, one should be able to build an arbitrary GLM(?). – Ben Reiniger Feb 26 at 20:39

## 2 Answers

No. A GLM is characterized by its link function and its target distribution. TweedieRegressor assumes a Tweedie distribution for the latter, which do not include the Bernoulli distribution needed for logistic regression.

Logistic regression corresponds to a Binomial distribution, a member of the exponential family, so in that sense it is nested within the Exponential Dispersion class of models. The $$\mathrm{Tweedie}(\mu, \sigma^2)$$ family specifically is also contained within $$\mathrm{ED}$$, but imposes the mean-variance relationship

\begin{align*} \mu &= \mathbf{E}[Y]\\ \operatorname{var}(Y) &= \sigma^2 \mu^p. \end{align*}

This cannot work for logistic regression because the Binomial needs $$\operatorname{var}(Y) = np(1-p) = n\mathbf{E}[Y](1-\mathbf{E}[Y]).$$