Skip to content

Commit 176ce44

Browse files
authored
MAINT: revert the deprecation of forest parameters to sync with sklearn (#475)
1 parent a19d398 commit 176ce44

File tree

2 files changed

+25
-30
lines changed

2 files changed

+25
-30
lines changed

doc/ensemble.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ provides all functionality of the
7878
BalancedRandomForestClassifier(...)
7979
>>> y_pred = brf.predict(X_test)
8080
>>> balanced_accuracy_score(y_test, y_pred) # doctest: +ELLIPSIS
81-
0.81...
81+
0.80...
8282
>>> brf.feature_importances_ # doctest: +ELLIPSIS
83-
array([ 0.55..., 0.44...])
83+
array([ 0.57..., 0.42...])
8484

8585
.. _boosting:
8686

@@ -98,7 +98,7 @@ a boosting iteration [SKHN2010]_::
9898
RUSBoostClassifier(...)
9999
>>> y_pred = rusboost.predict(X_test)
100100
>>> balanced_accuracy_score(y_test, y_pred) # doctest: +ELLIPSIS
101-
0.74770070758043261
101+
0.74...
102102

103103
A specific method which uses ``AdaBoost`` as learners in the bagging classifier
104104
is called EasyEnsemble. The :class:`EasyEnsembleClassifier` allows to bag
@@ -112,7 +112,7 @@ ensemble as::
112112
EasyEnsembleClassifier(...)
113113
>>> y_pred = eec.predict(X_test)
114114
>>> balanced_accuracy_score(y_test, y_pred) # doctest: +ELLIPSIS
115-
0.62484778593026025
115+
0.62...
116116

117117
.. topic:: Examples
118118

imblearn/ensemble/_forest.py

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,6 @@ class BalancedRandomForestClassifier(RandomForestClassifier):
6666
"gini" for the Gini impurity and "entropy" for the information gain.
6767
Note: this parameter is tree-specific.
6868
69-
max_features : int, float, string or None, optional (default="auto")
70-
The number of features to consider when looking for the best split:
71-
72-
- If int, then consider `max_features` features at each split.
73-
- If float, then `max_features` is a percentage and
74-
`int(max_features * n_features)` features are considered at each
75-
split.
76-
- If "auto", then `max_features=sqrt(n_features)`.
77-
- If "sqrt", then `max_features=sqrt(n_features)` (same as "auto").
78-
- If "log2", then `max_features=log2(n_features)`.
79-
- If None, then `max_features=n_features`.
80-
81-
Note: the search for a split does not stop until at least one
82-
valid partition of the node samples is found, even if it requires to
83-
effectively inspect more than ``max_features`` features.
84-
8569
max_depth : integer or None, optional (default=None)
8670
The maximum depth of the tree. If None, then nodes are expanded until
8771
all leaves are pure or until all leaves contain less than
@@ -108,10 +92,21 @@ class BalancedRandomForestClassifier(RandomForestClassifier):
10892
the input samples) required to be at a leaf node. Samples have
10993
equal weight when sample_weight is not provided.
11094
111-
.. deprecated:: 0.20
112-
The parameter ``min_weight_fraction_leaf`` is deprecated in version
113-
0.20. Its implementation, like ``min_samples_leaf``, is ineffective
114-
for regularization.
95+
max_features : int, float, string or None, optional (default="auto")
96+
The number of features to consider when looking for the best split:
97+
98+
- If int, then consider `max_features` features at each split.
99+
- If float, then `max_features` is a percentage and
100+
`int(max_features * n_features)` features are considered at each
101+
split.
102+
- If "auto", then `max_features=sqrt(n_features)`.
103+
- If "sqrt", then `max_features=sqrt(n_features)` (same as "auto").
104+
- If "log2", then `max_features=log2(n_features)`.
105+
- If None, then `max_features=n_features`.
106+
107+
Note: the search for a split does not stop until at least one
108+
valid partition of the node samples is found, even if it requires to
109+
effectively inspect more than ``max_features`` features.
115110
116111
max_leaf_nodes : int or None, optional (default=None)
117112
Grow trees with ``max_leaf_nodes`` in best-first fashion.
@@ -239,10 +234,10 @@ class labels (multi-output problem).
239234
>>> clf.fit(X, y) # doctest: +ELLIPSIS
240235
BalancedRandomForestClassifier(...)
241236
>>> print(clf.feature_importances_)
242-
[ 0.21521153 0.01054557 0.00689419 0.17404434 0.00414734 0.00704686
243-
0.19761999 0.01865445 0.00608294 0.00490484 0.00866699 0.0046718
244-
0.00359038 0.01168016 0.09392572 0.04978297 0.0033278 0.01008566
245-
0.15534173 0.01377474]
237+
[ 0.21506735 0.0104961 0.00706549 0.17414694 0.00556422 0.00704686
238+
0.19779549 0.01865445 0.00608294 0.00490484 0.00866699 0.00251414
239+
0.00339721 0.01174379 0.09380596 0.05049964 0.0033278 0.01008566
240+
0.15534173 0.01379241]
246241
>>> print(clf.predict([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
247242
... 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]))
248243
[1]
@@ -253,8 +248,8 @@ def __init__(self,
253248
criterion="gini",
254249
max_depth=None,
255250
min_samples_split=2,
256-
min_samples_leaf='deprecated',
257-
min_weight_fraction_leaf='deprecated',
251+
min_samples_leaf=2,
252+
min_weight_fraction_leaf=0.,
258253
max_features="auto",
259254
max_leaf_nodes=None,
260255
min_impurity_decrease=0.,

0 commit comments

Comments
 (0)