-
-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Closed
Labels
Description
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.