8000 Add explanation to the warning as well · scikit-learn/scikit-learn@7d63e66 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d63e66

Browse files
committed
Add explanation to the warning as well
1 parent e04af1c commit 7d63e66

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

sklearn/ensemble/_gb.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ def _check_initialized(self):
358358
"""Check that the estimator is initialized, raising an error if not."""
359359
check_is_fitted(self)
360360

361+
@abstractmethod
362+
def _warn_mae_for_criterion(self):
363+
pass
364+
361365
def fit(self, X, y, sample_weight=None, monitor=None):
362366
"""Fit the gradient boosting model.
363367
@@ -395,8 +399,7 @@ def fit(self, X, y, sample_weight=None, monitor=None):
395399
"""
396400
if self.criterion == 'mae':
397401
# 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()
400403

401404
# if not warmstart - clear the estimator state
402405
if not self.warm_start:
@@ -1111,6 +1114,14 @@ def _validate_y(self, y, sample_weight):
11111114
self.n_classes_ = self._n_classes
11121115
return y
11131116

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+
11141125
def decision_function(self, X):
11151126
"""Compute the decision function of ``X``.
11161127
@@ -1614,6 +1625,13 @@ def _validate_y(self, y, sample_weight=None):
16141625
y = y.astype(DOUBLE)
16151626
return y
16161627

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+
16171635
def predict(self, X):
16181636
"""Predict regression target for X.
16191637

0 commit comments

Comments
 (0)
0