@@ -431,15 +431,15 @@ def params_to_dict(self):
431431 return dict ()
432432
433433 def initialize (self , X , y ):
434- if np .any (y <= 0 ):
434+ if np .any (y < 0 ):
435435 raise ValueError (
436- "Target vector `y` should only take positive values " +
436+ "Target vector `y` should only take positive values "
437437 "when fitting a Poisson model." )
438438
439439 def initialize_sparse (self , X_data , X_indptr , X_indices , y ):
440- if np .any (y <= 0 ):
440+ if np .any (y < 0 ):
441441 raise ValueError (
442- "Target vector `y` should only take positive values " +
442+ "Target vector `y` should only take positive values "
443443 "when fitting a Poisson model." )
444444
445445 def raw_grad (self , y , Xw ):
@@ -453,6 +453,9 @@ def raw_hessian(self, y, Xw):
453453 def value (self , y , w , Xw ):
454454 return np .sum (np .exp (Xw ) - y * Xw ) / len (y )
455455
456+ def gradient (self , X , y , Xw ):
457+ return X .T @ self .raw_grad (y , Xw )
458+
456459 def gradient_scalar (self , X , y , w , Xw , j ):
457460 return (X [:, j ] @ (np .exp (Xw ) - y )) / len (y )
458461
0 commit comments