Skip to content

Remove link argument from TweedieRegressor #19086

@lorentzenchr

Description

@lorentzenchr

Proposal

Remove the argument link from TweedieRegressor and always use a log-link.

Rationale

While PoissonRegressor and GammaRegressor have built-in log-link (prediction = exp(..)), the TweedieRegressor has an argument link : {'auto', 'identity', 'log'}, default='auto'.

The problem is that Tweedie should always predict positive vallues, but with link=identity`' this goes wrong, for example

import numpy as np
from sklearn.linear_model import TweedieRegressor


y = np.array([3, 2, 1, 0, 0])
X = np.arange(5)[:, None]
reg = TweedieRegressor(power=1, link='identity')  # power=1 optimizes Poisson deviance
reg.fit(X, y)
reg.predict(X)
Out[7]: array([ 1.95131702,  0.45263687, -1.04604328, -2.54472343, -4.04340359])

The only instance, where negatives predictions are ok, is power=0 which gives squared error. But if someone want't to fit squared error, she or he should better use Ridge and the likes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions