@@ -56,9 +56,9 @@ The disadvantages of decision trees include:
56
56
57
57
- Decision-tree learners can create over-complex trees that do not
58
58
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.
62
62
63
63
- Decision trees can be unstable because small variations in the
64
64
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::
124
124
>>> clf = tree.DecisionTreeClassifier()
125
125
>>> clf = clf.fit(X, y)
126
126
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::
128
128
129
129
130
- >>> tree.plot_tree(clf.fit(iris.data, iris.target) ) # doctest: +SKIP
130
+ >>> tree.plot_tree(clf) # doctest: +SKIP
131
131
132
132
.. figure :: ../auto_examples/tree/images/sphx_glr_plot_iris_dtc_002.png
133
133
:target: ../auto_examples/tree/plot_iris_dtc.html
@@ -137,10 +137,7 @@ Once trained, you can plot the tree with the plot_tree function::
137
137
We can also export the tree in `Graphviz
138
138
<https://www.graphviz.org/> `_ format using the :func: `export_graphviz `
139
139
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 `.
144
141
145
142
Alternatively binaries for graphviz can be downloaded from the graphviz project homepage,
146
143
and the Python wrapper installed from pypi with `pip install graphviz `.
@@ -188,7 +185,7 @@ of external libraries and is more compact:
188
185
189
186
>>> from sklearn.datasets import load_iris
190
187
>>> from sklearn.tree import DecisionTreeClassifier
191
- >>> from sklearn.tree.export import export_text
188
+ >>> from sklearn.tree import export_text
192
189
>>> iris = load_iris()
193
190
>>> decision_tree = DecisionTreeClassifier(random_state = 0 , max_depth = 2 )
194
191
>>> decision_tree = decision_tree.fit(iris.data, iris.target)
0 commit comments