@@ -822,6 +822,11 @@ def get_leaf_node_samples(self, X):
822
822
samples, since the number of samples that fall in a leaf node is
823
823
variable. Each array-like has shape (n_leaf_node_samples, n_outputs).
824
824
"""
825
+ if not self .store_leaf_values :
826
+ raise RuntimeError (
827
+ "Leaf node samples are not available when store_leaf_values=False"
828
+ )
829
+
825
830
check_is_fitted (self )
826
831
# Check data
827
832
X = self ._validate_X_predict (X )
@@ -1520,6 +1525,9 @@ class RandomForestClassifier(ForestClassifier):
1520
1525
1521
1526
.. versionadded:: 0.22
1522
1527
1528
+ store_leaf_values : bool, default=False
1529
+ Whether to store the leaf values in the ``get_leaf_node_samples`` function.
1530
+
1523
1531
Attributes
1524
1532
----------
1525
1533
estimator_ : :class:`~sklearn.tree.DecisionTreeClassifier`
@@ -1879,6 +1887,9 @@ class RandomForestRegressor(ForestRegressor):
1879
1887
1880
1888
.. versionadded:: 0.22
1881
1889
1890
+ store_leaf_values : bool, default=False
1891
+ Whether to store the leaf values in the ``get_leaf_node_samples`` function.
1892
+
1882
1893
Attributes
1883
1894
----------
1884
1895
estimator_ : :class:`~sklearn.tree.DecisionTreeRegressor`
@@ -2232,6 +2243,9 @@ class ExtraTreesClassifier(ForestClassifier):
2232
2243
2233
2244
.. versionadded:: 0.22
2234
2245
2246
+ store_leaf_values : bool, default=False
2247
+ Whether to store the leaf values in the ``get_leaf_node_samples`` function.
2248
+
2235
2249
Attributes
2236
2250
----------
2237
2251
estimator_ : :class:`~sklearn.tree.ExtraTreesClassifier`
@@ -2576,6 +2590,9 @@ class ExtraTreesRegressor(ForestRegressor):
2576
2590
2577
2591
.. versionadded:: 0.22
2578
2592
2593
+ store_leaf_values : bool, default=False
2594
+ Whether to store the leaf values in the ``get_leaf_node_samples`` function.
2595
+
2579
2596
Attributes
2580
2597
----------
2581
2598
estimator_ : :class:`~sklearn.tree.ExtraTreeRegressor`
0 commit comments