@@ -358,6 +358,10 @@ def _check_initialized(self):
358
358
"""Check that the estimator is initialized, raising an error if not."""
359
359
check_is_fitted (self )
360
360
361
+ @abstractmethod
362
+ def _warn_mae_for_criterion (self ):
363
+ pass
364
+
361
365
def fit (self , X , y , sample_weight = None , monitor = None ):
362
366
"""Fit the gradient boosting model.
363
367
@@ -395,8 +399,7 @@ def fit(self, X, y, sample_weight=None, monitor=None):
395
399
"""
396
400
if self .criterion == 'mae' :
397
401
# TODO: This should raise an error from 0.26
398
- warnings .warn ("criterion='mae' was deprecated in version 0.24 and "
399
- "will be removed in version 0.26." , FutureWarning )
402
+ self ._warn_mae_for_criterion ()
400
403
401
404
# if not warmstart - clear the estimator state
402
405
if not self .warm_start :
@@ -1111,6 +1114,14 @@ def _validate_y(self, y, sample_weight):
1111
1114
self .n_classes_ = self ._n_classes
1112
1115
return y
1113
1116
1117
+ def _warn_mae_for_criterion (self ):
1118
+ # TODO: This should raise an error from 0.26
1119
+ warnings .warn ("criterion='mae' was deprecated in version 0.24 and "
1120
+ "will be removed in version 0.26. Use "
1121
+ "criterion='friedman_mse' or 'mse' instead, as trees "
1122
+ "should use a least-square criterion in Gradient "
1123
+ "Boosting." , FutureWarning )
1124
+
1114
1125
def decision_function (self , X ):
1115
1126
"""Compute the decision function of ``X``.
1116
1127
@@ -1614,6 +1625,13 @@ def _validate_y(self, y, sample_weight=None):
1614
1625
y = y .astype (DOUBLE )
1615
1626
return y
1616
1627
1628
+ def _warn_mae_for_criterion (self ):
1629
+ # TODO: This should raise an error from 0.26
1630
+ warnings .warn ("criterion='mae' was deprecated in version 0.24 and "
1631
+ "will be removed in version 0.26. The correct way of "
1632
+ "minimizing the absolute error is to use loss='lad' "
1633
+ "instead." , FutureWarning )
1634
+
1617
1635
def predict (self , X ):
1618
1636
"""Predict regression target for X.
1619
1637
0 commit comments