@@ -358,6 +358,10 @@ def _check_initialized(self):
358
358
"""Check that the estimator is initialized, raising an error if not.&
8000
quot;""
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
@@ -393,6 +397,10 @@ def fit(self, X, y, sample_weight=None, monitor=None):
393
397
-------
394
398
self : object
395
399
"""
400
+ if self .criterion == 'mae' :
401
+ # TODO: This should raise an error from 0.26
402
+ self ._warn_mae_for_criterion ()
403
+
396
404
# if not warmstart - clear the estimator state
397
405
if not self .warm_start :
398
406
self ._clear_state ()
@@ -802,6 +810,10 @@ class GradientBoostingClassifier(ClassifierMixin, BaseGradientBoosting):
802
810
some cases.
803
811
804
812
.. versionadded:: 0.18
813
+ .. deprecated:: 0.24
814
+ `criterion='mae'` is deprecated and will be removed in version
815
+ 0.26. Use `criterion='friedman_mse'` or `'mse'` instead, as trees
816
+ should use a least-square criterion in Gradient Boosting.
805
817
806
818
min_samples_split : int or float, default=2
807
819
The minimum number of samples required to split an internal node:
@@ -1102,6 +1114,14 @@ def _validate_y(self, y, sample_weight):
1102
1114
self .n_classes_ = self ._n_classes
1103
1115
return y
1104
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
+
1105
1125
def decision_function (self , X ):
1106
1126
"""Compute the decision function of ``X``.
1107
1127
@@ -1320,6 +1340,10 @@ class GradientBoostingRegressor(RegressorMixin, BaseGradientBoosting):
1320
1340
some cases.
1321
1341
1322
1342
.. versionadded:: 0.18
1343
+ .. deprecated:: 0.24
1344
+ `criterion='mae'` is deprecated and will be removed in version
1345
+ 0.26. The correct way of minimizing the absolute error is to use
1346
+ `loss='lad'` instead.
1323
1347
1324
1348
min_samples_split : int or float, default=2
1325
1349
The minimum number of samples required to split an internal node:
@@ -1601,6 +1625,13 @@ def _validate_y(self, y, sample_weight=None):
1601
1625
y = y .astype (DOUBLE )
1602
1626
return y
1603
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
+
1604
1635
def predict (self , X ):
1605
1636
"""Predict regression target for X.
1606
1637
0 commit comments