Skip to content

Commit 216204f

Browse files
ndawearjoly
authored andcommitted
forest: add min_weight_fraction_leaf
1 parent 7e9c093 commit 216204f

File tree

1 file changed

+49
-10
lines changed

1 file changed

+49
-10
lines changed

sklearn/ensemble/forest.py

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,11 @@ class RandomForestClassifier(ForestClassifier):
669669
``min_samples_leaf`` samples.
670670
Note: this parameter is tree-specific.
671671
672+
min_weight_fraction_leaf : float, optional (default=0.)
673+
The minimum weighted fraction of the input samples required to be at a
674+
leaf node.
675+
Note: this parameter is tree-specific.
676+
672677
max_leaf_nodes : int or None, optional (default=None)
673678
Grow trees with ``max_leaf_nodes`` in best-first fashion.
674679
Best nodes are defined as relative reduction in impurity.
@@ -736,6 +741,7 @@ def __init__(self,
736741
max_depth=None,
737742
min_samples_split=2,
738743
min_samples_leaf=1,
744+
min_weight_fraction_leaf=0.,
739745
max_features="auto",
740746
max_leaf_nodes=None,
741747
bootstrap=True,
@@ -749,8 +755,9 @@ def __init__(self,
749755
base_estimator=DecisionTreeClassifier(),
750756
n_estimators=n_estimators,
751757
estimator_params=("criterion", "max_depth", "min_samples_split",
752-
"min_samples_leaf", "max_features",
753-
"max_leaf_nodes", "random_state"),
758+
"min_samples_leaf", "min_weight_fraction_leaf",
759+
"max_features", "max_leaf_nodes",
760+
"random_state"),
754761
bootstrap=bootstrap,
755762
oob_score=oob_score,
756763
n_jobs=n_jobs,
@@ -761,6 +768,7 @@ def __init__(self,
761768
self.max_depth = max_depth
762769
self.min_samples_split = min_samples_split
763770
self.min_samples_leaf = min_samples_leaf
771+
self.min_weight_fraction_leaf = min_weight_fraction_leaf
764772
self.max_features = max_features
765773
self.max_leaf_nodes = max_leaf_nodes
766774

@@ -827,6 +835,11 @@ class RandomForestRegressor(ForestRegressor):
827835
``min_samples_leaf`` samples.
828836
Note: this parameter is tree-specific.
829837
838+
min_weight_fraction_leaf : float, optional (default=0.)
839+
The minimum weighted fraction of the input samples required to be at a
840+
leaf node.
841+
Note: this parameter is tree-specific.
842+
830843
max_leaf_nodes : int or None, optional (default=None)
831844
Grow trees with ``max_leaf_nodes`` in best-first fashion.
832845
Best nodes are defined as relative reduction in impurity.
@@ -883,6 +896,7 @@ def __init__(self,
883896
max_depth=None,
884897
min_samples_split=2,
885898
min_samples_leaf=1,
899+
min_weight_fraction_leaf=0.,
886900
max_features="auto",
887901
max_leaf_nodes=None,
888902
bootstrap=True,
@@ -896,8 +910,9 @@ def __init__(self,
896910
base_estimator=DecisionTreeRegressor(),
897911
n_estimators=n_estimators,
898912
estimator_params=("criterion", "max_depth", "min_samples_split",
899-
"min_samples_leaf", "max_features",
900-
"max_leaf_nodes", "random_state"),
913+
"min_samples_leaf", "min_weight_fraction_leaf",
914+
"max_features", "max_leaf_nodes",
915+
"random_state"),
901916
bootstrap=bootstrap,
902917
oob_score=oob_score,
903918
n_jobs=n_jobs,
@@ -908,6 +923,7 @@ def __init__(self,
908923
self.max_depth = max_depth
909924
self.min_samples_split = min_samples_split
910925
self.min_samples_leaf = min_samples_leaf
926+
self.min_weight_fraction_leaf = min_weight_fraction_leaf
911927
self.max_features = max_features
912928
self.max_leaf_nodes = max_leaf_nodes
913929

@@ -975,6 +991,11 @@ class ExtraTreesClassifier(ForestClassifier):
975991
``min_samples_leaf`` samples.
976992
Note: this parameter is tree-specific.
977993
994+
min_weight_fraction_leaf : float, optional (default=0.)
995+
The minimum weighted fraction of the input samples required to be at a
996+
leaf node.
997+
Note: this parameter is tree-specific.
998+
978999
max_leaf_nodes : int or None, optional (default=None)
9791000
Grow trees with ``max_leaf_nodes`` in best-first fashion.
9801001
Best nodes are defined as relative reduction in impurity.
@@ -1045,6 +1066,7 @@ def __init__(self,
10451066
max_depth=None,
10461067
min_samples_split=2,
10471068
min_samples_leaf=1,
1069+
min_weight_fraction_leaf=0.,
10481070
max_features="auto",
10491071
max_leaf_nodes=None,
10501072
bootstrap=False,
@@ -1058,8 +1080,8 @@ def __init__(self,
10581080
base_estimator=ExtraTreeClassifier(),
10591081
n_estimators=n_estimators,
10601082
estimator_params=("criterion", "max_depth", "min_samples_split",
1061-
"min_samples_leaf", "max_features",
1062-
"max_leaf_nodes", "random_state"),
1083+
"min_samples_leaf", "min_weight_fraction_leaf",
1084+
"max_features", "max_leaf_nodes", "random_state"),
10631085
bootstrap=bootstrap,
10641086
oob_score=oob_score,
10651087
n_jobs=n_jobs,
@@ -1070,6 +1092,7 @@ def __init__(self,
10701092
self.max_depth = max_depth
10711093
self.min_samples_split = min_samples_split
10721094
self.min_samples_leaf = min_samples_leaf
1095+
self.min_weight_fraction_leaf = min_weight_fraction_leaf
10731096
self.max_features = max_features
10741097
self.max_leaf_nodes = max_leaf_nodes
10751098

@@ -1137,6 +1160,11 @@ class ExtraTreesRegressor(ForestRegressor):
11371160
``min_samples_leaf`` samples.
11381161
Note: this parameter is tree-specific.
11391162
1163+
min_weight_fraction_leaf : float, optional (default=0.)
1164+
The minimum weighted fraction of the input samples required to be at a
1165+
leaf node.
1166+
Note: this parameter is tree-specific.
1167+
11401168
max_leaf_nodes : int or None, optional (default=None)
11411169
Grow trees with ``max_leaf_nodes`` in best-first fashion.
11421170
Best nodes are defined as relative reduction in impurity.
@@ -1196,6 +1224,7 @@ def __init__(self,
11961224
max_depth=None,
11971225
min_samples_split=2,
11981226
min_samples_leaf=1,
1227+
min_weight_fraction_leaf=0.,
11991228
max_features="auto",
12001229
max_leaf_nodes=None,
12011230
bootstrap=False,
@@ -1209,8 +1238,9 @@ def __init__(self,
12091238
base_estimator=ExtraTreeRegressor(),
12101239
n_estimators=n_estimators,
12111240
estimator_params=("criterion", "max_depth", "min_samples_split",
1212-
"min_samples_leaf", "max_features",
1213-
"max_leaf_nodes", "random_state"),
1241+
"min_samples_leaf", "min_weight_fraction_leaf",
1242+
"max_features", "max_leaf_nodes",
1243+
"random_state"),
12141244
bootstrap=bootstrap,
12151245
oob_score=oob_score,
12161246
n_jobs=n_jobs,
@@ -1221,6 +1251,7 @@ def __init__(self,
12211251
self.max_depth = max_depth
12221252
self.min_samples_split = min_samples_split
12231253
self.min_samples_leaf = min_samples_leaf
1254+
self.min_weight_fraction_leaf = min_weight_fraction_leaf
12241255
self.max_features = max_features
12251256
self.max_leaf_nodes = max_leaf_nodes
12261257

@@ -1268,6 +1299,11 @@ class RandomTreesEmbedding(BaseForest):
12681299
``min_samples_leaf`` samples.
12691300
Note: this parameter is tree-specific.
12701301
1302+
min_weight_fraction_leaf : float, optional (default=0.)
1303+
The minimum weighted fraction of the input samples required to be at a
1304+
leaf node.
1305+
Note: this parameter is tree-specific.
1306+
12711307
max_leaf_nodes : int or None, optional (default=None)
12721308
Grow trees with ``max_leaf_nodes`` in best-first fashion.
12731309
Best nodes are defined as relative reduction in impurity.
@@ -1312,6 +1348,7 @@ def __init__(self,
13121348
max_depth=5,
13131349
min_samples_split=2,
13141350
min_samples_leaf=1,
1351+
min_weight_fraction_leaf=0.,
13151352
max_leaf_nodes=None,
13161353
sparse_output=True,
13171354
n_jobs=1,
@@ -1322,8 +1359,9 @@ def __init__(self,
13221359
base_estimator=ExtraTreeRegressor(),
13231360
n_estimators=n_estimators,
13241361
estimator_params=("criterion", "max_depth", "min_samples_split",
1325-
"min_samples_leaf", "max_features",
1326-
"max_leaf_nodes", "random_state"),
1362+
"min_samples_leaf", "min_weight_fraction_leaf",
1363+
"max_features", "max_leaf_nodes",
1364+
"random_state"),
13271365
bootstrap=False,
13281366
oob_score=False,
13291367
n_jobs=n_jobs,
@@ -1334,6 +1372,7 @@ def __init__(self,
13341372
self.max_depth = max_depth
13351373
self.min_samples_split = min_samples_split
13361374
self.min_samples_leaf = min_samples_leaf
1375+
self.min_weight_fraction_leaf = min_weight_fraction_leaf
13371376
self.max_features = 1
13381377
self.max_leaf_nodes = max_leaf_nodes
13391378
self.sparse_output = sparse_output

0 commit comments

Comments
 (0)