8000 DOC Minor updates to the Decision Tree User Guide by justmarkham · Pull Request #16905 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

DOC Minor updates to the Decision Tree User Guide #16905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions doc/modules/tree.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ The disadvantages of decision trees include:

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

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

Once trained, you can plot the tree with the plot_tree function::
Once trained, you can plot the tree with the :func:`plot_tree` function::


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

.. figure:: ../auto_examples/tree/images/sphx_glr_plot_iris_dtc_002.png
:target: ../auto_examples/tree/plot_iris_dtc.html
Expand All @@ -137,10 +137,7 @@ Once trained, you can plot the tree with the plot_tree function::
We can also export the tree in `Graphviz
<https://www.graphviz.org/>`_ format using the :func:`export_graphviz`
exporter. If you use the `conda <https://conda.io>`_ package manager, the graphviz binaries

and the python package can be installed with

conda install python-graphviz
and the python package can be installed with `conda install python-graphviz`.
Comment on lines -141 to +140
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this change is necessary, but LGTM anyway.


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

>>> from sklearn.datasets import load_iris
>>> from sklearn.tree import DecisionTreeClassifier
>>> from sklearn.tree.export import export_text
>>> from sklearn.tree import export_text
>>> iris = load_iris()
>>> decision_tree = DecisionTreeClassifier(random_state=0, max_depth=2)
>>> decision_tree = decision_tree.fit(iris.data, iris.target)
Expand Down
0