Skip to content

Commit f7fd231

Browse files
nilichenJonathan RahnKatrina Ni
authored
DOC add example to tree.ExtraTreeClassifier (scikit-learn#16671)
Co-authored-by: Jonathan Rahn <jonathan.rahn@42digital.de> Co-authored-by: Katrina Ni <kani@tableau.com>
1 parent 862a726 commit f7fd231

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

sklearn/tree/_classes.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,21 @@ class ExtraTreeClassifier(DecisionTreeClassifier):
14771477
14781478
.. [1] P. Geurts, D. Ernst., and L. Wehenkel, "Extremely randomized trees",
14791479
Machine Learning, 63(1), 3-42, 2006.
1480+
1481+
Examples
1482+
--------
1483+
>>> from sklearn.datasets import load_iris
1484+
>>> from sklearn.model_selection import train_test_split
1485+
>>> from sklearn.ensemble import BaggingClassifier
1486+
>>> from sklearn.tree import ExtraTreeClassifier
1487+
>>> X, y = load_iris(return_X_y=True)
1488+
>>> X_train, X_test, y_train, y_test = train_test_split(
1489+
... X, y, random_state=0)
1490+
>>> extra_tree = ExtraTreeClassifier(random_state=0)
1491+
>>> cls = BaggingClassifier(extra_tree, random_state=0).fit(
1492+
... X_train, y_train)
1493+
>>> cls.score(X_test, y_test)
1494+
0.8947...
14801495
"""
14811496
def __init__(self,
14821497
criterion="gini",

0 commit comments

Comments
 (0)