Skip to content

Commit fdf2e2d

Browse files
committed
Added doc to store_leaf_values
Signed-off-by: Adam Li <adam2392@gmail.com>
1 parent 4840d4e commit fdf2e2d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

sklearn/ensemble/_forest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,11 @@ def get_leaf_node_samples(self, X):
822822
samples, since the number of samples that fall in a leaf node is
823823
variable. Each array-like has shape (n_leaf_node_samples, n_outputs).
824824
"""
825+
if not self.store_leaf_values:
826+
raise RuntimeError(
827+
"Leaf node samples are not available when store_leaf_values=False"
828+
)
829+
825830
check_is_fitted(self)
826831
# Check data
827832
X = self._validate_X_predict(X)
@@ -1520,6 +1525,9 @@ class RandomForestClassifier(ForestClassifier):
15201525
15211526
.. versionadded:: 0.22
15221527
1528+
store_leaf_values : bool, default=False
1529+
Whether to store the leaf values in the ``get_leaf_node_samples`` function.
1530+
15231531
Attributes
15241532
----------
15251533
estimator_ : :class:`~sklearn.tree.DecisionTreeClassifier`
@@ -1879,6 +1887,9 @@ class RandomForestRegressor(ForestRegressor):
18791887
18801888
.. versionadded:: 0.22
18811889
1890+
store_leaf_values : bool, default=False
1891+
Whether to store the leaf values in the ``get_leaf_node_samples`` function.
1892+
18821893
Attributes
18831894
----------
18841895
estimator_ : :class:`~sklearn.tree.DecisionTreeRegressor`
@@ -2232,6 +2243,9 @@ class ExtraTreesClassifier(ForestClassifier):
22322243
22332244
.. versionadded:: 0.22
22342245
2246+
store_leaf_values : bool, default=False
2247+
Whether to store the leaf values in the ``get_leaf_node_samples`` function.
2248+
22352249
Attributes
22362250
----------
22372251
estimator_ : :class:`~sklearn.tree.ExtraTreesClassifier`
@@ -2576,6 +2590,9 @@ class ExtraTreesRegressor(ForestRegressor):
25762590
25772591
.. versionadded:: 0.22
25782592
2593+
store_leaf_values : bool, default=False
2594+
Whether to store the leaf values in the ``get_leaf_node_samples`` function.
2595+
25792596
Attributes
25802597
----------
25812598
estimator_ : :class:`~sklearn.tree.ExtraTreeRegressor`

0 commit comments

Comments
 (0)