liveBook · Manning

TweedieRegressor

As explained in Ensemble Methods for Machine Learning

TweedieRegressor is a scikit-learn estimator that fits generalized linear regression with a Tweedie distribution and log link.

TweedieRegressor fits a generalized linear regression model with a Tweedie distribution and log link. It is useful when targets combine many zeros with positive, right-skewed values, such as insurance, weather, health, or rental outcomes. section 7.1.4 section 7.5

Configure the estimator around two important hyperparameters:

  • Set alpha to control the L2 regularization term. section 7.4.2
  • Search power between 1 and 2 to tune the Tweedie distribution; power=1 is equivalent to PoissonRegressor. section 7.4.2
  • Compare predictions with MSE, MAE, and R2, rather than assuming a normal-error model is appropriate. section 7.4.2

Bike-rental prediction

A grid search varies alpha and power while training TweedieRegressor(max_iter=1000). On the bike-rental data, the tuned Tweedie model obtains test MSE 1,254.304, test MAE 20.661, and test R2 0.454. It can also serve as a base estimator in a stacking ensemble.

Table 7.2 GLMs for different types of labels (view table figure)

Model

Link function

Distribution

Type of label

Linear regression

Identity

g(y) = y

Normal

Real-valued

Gamma regression

Negative inverse g(y) = -(1/y)

Gamma

Positive real-valued

Poisson regression

Log g(y) = log(y)

Poisson

Counts/occurrences; integer-valued

Logistic regression

Logit g(y) = (y/(1-y))

Bernoulli

0-1; binary class labels; yes/no outcomes

Multiclass logistic regression

Multiclass logit g(y) = (y/(K-y))

Binomial

0-K; multiclass labels; multichoice outcomes

Tweedie regression

Log g(y) = ln(y)

Tweedie

Labels with many zeros, right-skewed targets

Compare Tweedie regression with linear, Gamma, Poisson, and logistic GLMs by link function, distribution, and target type. section 7.1.4

How Ensemble Methods for Machine Learning covers it

How deep it goes
Explains the log link, distribution choice, regularization, power search, evaluation, and stacking, without deriving the Tweedie likelihood.
Examples
Uses bike-rental prediction, GridSearchCV, train-test metrics, and a stacked GLM ensemble.
What it assumes
Assumes familiarity with regression, generalized linear models, distributions, regularization, train-test evaluation, and ensemble stacking.
What you can do after
Operate/configure TweedieRegressor through scikit-learn, tune alpha and power, evaluate predictions, and include it in a stacking ensemble.
How it connects
Connects generalized linear models with Poisson regression, Gamma regression, Ridge regression, hyperparameter search, and stacking ensembles.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Ensemble Methods for Machine Learning. The section links point to the parts of the book it draws on.