Skip to content

Commit 05f1edb

Browse files
make inverse_link the identity by default for API consistency
1 parent 58587cc commit 05f1edb

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

skglm/datafits/base.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
class BaseDatafit:
33
"""Base class for datafits."""
44

5+
@staticmethod
6+
def inverse_link(x):
7+
"""Inverse link function (identity by default).
8+
9+
Parameters
10+
----------
11+
x : array-like
12+
Linear predictor values.
13+
14+
Returns
15+
-------
16+
array-like
17+
Transformed values in response scale.
18+
"""
19+
return x
20+
521
def get_spec(self):
622
"""Specify the numba types of the class attributes.
723

skglm/estimators.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,8 @@ def predict(self, X):
266266
else:
267267
indices = scores.argmax(axis=1)
268268
return self.classes_[indices]
269-
elif hasattr(self.datafit, "inverse_link"):
270-
return self.datafit.inverse_link(self._decision_function(X))
271269
else:
272-
return self._decision_function(X)
270+
return self.datafit.inverse_link(self._decision_function(X))
273271

274272
def get_params(self, deep=False):
275273
"""Get parameters of the estimators including the datafit's and penalty's.

0 commit comments

Comments
 (0)