8000 DOC Minor updates to the Decision Tree User Guide (#16905) · NicolasHug/scikit-learn@bd9fd0f · GitHub
[go: up one dir, main page]

Skip to content

Commit bd9fd0f

Browse files
authored
DOC Minor updates to the Decision Tree User Guide (scikit-learn#16905)
1 parent 9901d8d commit bd9fd0f

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

doc/modules/tree.rst

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ The disadvantages of decision trees include:
5656

5757
- Decision-tree learners can create over-complex trees that do not
5858
generalise the data well. This is called overfitting. Mechanisms
59-
such as pruning (not currently supported), setting the minimum
60-
number of samples required at a leaf node or setting the maximum
61-
depth of the tree are necessary to avoid this problem.
59+
such as pruning, setting the minimum number of samples required
60+
at a leaf node or setting the maximum depth of the tree are
61+
necessary to avoid this problem.
6262

6363
- Decision trees can be unstable because small variations in the
6464
data might result in a completely different tree being generated.
@@ -124,10 +124,10 @@ Using the Iris dataset, we can construct a tree as follows::
124124
>>> clf = tree.DecisionTreeClassifier()
125125
>>> clf = clf.fit(X, y)
126126

127-
Once trained, you can plot the tree with the plot_tree function::
127+
Once trained, you can plot the tree with the :func:`plot_tree` function::
128128

129129

130-
>>> tree.plot_tree(clf.fit(iris.data, iris.target)) # doctest: +SKIP
130+
>>> tree.plot_tree(clf) # doctest: +SKIP
131131

132132
.. figure:: ../auto_examples/tree/images/sphx_glr_plot_iris_dtc_002.png
133133
:target: ../auto_examples/tree/plot_iris_dtc.html
@@ -137,10 +137,7 @@ Once trained, you can plot the tree with the plot_tree function::
137137
We can also export the tree in `Graphviz
138138
<https://www.graphviz.org/>`_ format using the :func:`export_graphviz`
139139
exporter. If you use the `conda <https://conda.io>`_ package manager, the graphviz binaries
140-
141-
and the python package can be installed with
142-
143-
conda install python-graphviz
140+
and the python package can be installed with `conda install python-graphviz`.
144141

145142
Alternatively binaries for graphviz can be downloaded from the graphviz project homepage,
146143
and the Python wrapper installed from pypi with `pip install graphviz`.
@@ -188,7 +185,7 @@ of external libraries and is more compact:
188185

189186
>>> from sklearn.datasets import load_iris
190187
>>> from sklearn.tree import DecisionTreeClassifier
191-
>>> from sklearn.tree.export import export_text
188+
>>> from sklearn.tree import export_text
192189
>>> iris = load_iris()
193190
>>> decision_tree = DecisionTreeClassifier(random_state=0, max_depth=2)
194191
>>> decision_tree = decision_tree.fit(iris.data, iris.target)

0 commit comments

Comments
 (0)
0