@@ -79,7 +79,6 @@ class IdentityLink(Link):
79
79
def __eq__ (self , other ): # noqa D
80
80
return isinstance (other , self .__class__ )
81
81
82
- # unnecessary type hint for consistency with other methods
83
82
def link (self , mu ):
84
83
"""Return mu (identity link).
85
84
@@ -102,7 +101,6 @@ def derivative(self, mu):
102
101
"""
103
102
return 1.0 if np .isscalar (mu ) else np .ones_like (mu )
104
103
105
- # unnecessary type hint for consistency with other methods
106
104
def inverse (self , lin_pred ):
107
105
"""Compute the inverse link function ``h(lin_pred)``.
108
106
@@ -156,7 +154,7 @@ def link(self, mu):
156
154
-------
157
155
numpy.ndarray
158
156
"""
159
- return np .log (mu )
157
+ return np .log (_asanyarray ( mu ) )
160
158
161
159
def derivative (self , mu ):
162
160
"""Get the derivative of the log link, one over ``mu``.
@@ -169,7 +167,7 @@ def derivative(self, mu):
169
167
-------
170
168
numpy.ndarray
171
169
"""
172
- return 1 / mu
170
+ return 1 / _asanyarray ( mu )
173
171
174
172
def inverse (self , lin_pred ):
175
173
"""Get the inverse of the log link, the exponential function.
@@ -184,7 +182,7 @@ def inverse(self, lin_pred):
184
182
-------
185
183
numpy.ndarray
186
184
"""
187
- return np .exp (lin_pred )
185
+ return np .exp (_asanyarray ( lin_pred ) )
188
186
189
187
def inverse_derivative (self , lin_pred ):
190
188
"""Compute the derivative of the inverse link function ``h'(lin_pred)``.
@@ -194,17 +192,17 @@ def inverse_derivative(self, lin_pred):
194
192
lin_pred : array-like, shape (n_samples,)
195
193
Usually the (fitted) linear predictor.
196
194
"""
197
- return np .exp (lin_pred )
195
+ return np .exp (_asanyarray ( lin_pred ) )
198
196
199
197
def inverse_derivative2 (self , lin_pred ):
200
- """Compute 2nd derivative of the inverse link function ``h''(lin_pred)``.
198
+ """Compute second derivative of the inverse link function ``h''(lin_pred)``.
201
199
202
200
Parameters
203
201
----------
204
202
lin_pred : array-like, shape (n_samples,)
205
203
Usually the (fitted) linear predictor.
206
204
"""
207
- return np .exp (lin_pred )
205
+ return np .exp (_asanyarray ( lin_pred ) )
208
206
209
207
210
208
class LogitLink (Link ):
@@ -282,7 +280,7 @@ def inverse_derivative(self, lin_pred):
282
280
return ep * (1.0 - ep )
283
281
284
282
def inverse_derivative2 (self , lin_pred ):
285
- """Compute 2nd derivative of the inverse link function ``h''(lin_pred)``.
283
+ """Compute second derivative of the inverse link function ``h''(lin_pred)``.
286
284
287
285
Parameters
288
286
----------
@@ -394,7 +392,7 @@ def inverse_derivative(self, lin_pred):
394
392
395
393
@catch_p
396
394
def inverse_derivative2 (self , lin_pred ):
397
- """Compute secondnd derivative of the inverse Tweedie link function \
395
+ """Compute second derivative of the inverse Tweedie link function \
398
396
``h''(lin_pred)``.
399
397
400
398
Parameters
@@ -484,7 +482,7 @@ def inverse_derivative(self, lin_pred):
484
482
return np .exp (lin_pred - np .exp (lin_pred ))
485
483
486
484
def inverse_derivative2 (self , lin_pred ):
487
- """Compute 2nd derivative of the inverse link function ``h''(lin_pred)``.
485
+ """Compute second derivative of the inverse link function ``h''(lin_pred)``.
488
486
489
487
Parameters
490
488
----------
0 commit comments