

.. _sphx_glr_auto_examples_tree:

.. _tree_examples:

Decision Trees
--------------

Examples concerning the :mod:`sklearn.tree` module.



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Decision Tree Regression">

.. only:: html

  .. image:: /auto_examples/tree/images/thumb/sphx_glr_plot_tree_regression_thumb.png
    :alt:

  :doc:`/auto_examples/tree/plot_tree_regression`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Decision Tree Regression</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Plot the decision surface of a decision tree trained on pairs of features of the iris dataset.">

.. only:: html

  .. image:: /auto_examples/tree/images/thumb/sphx_glr_plot_iris_dtc_thumb.png
    :alt:

  :doc:`/auto_examples/tree/plot_iris_dtc`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Plot the decision surface of decision trees trained on the iris dataset</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The DecisionTreeClassifier provides parameters such as min_samples_leaf and max_depth to prevent a tree from overfitting. Cost complexity pruning provides another option to control the size of a tree. In DecisionTreeClassifier, this pruning technique is parameterized by the cost complexity parameter, ccp_alpha. Greater values of ccp_alpha increase the number of nodes pruned. Here we only show the effect of ccp_alpha on regularizing the trees and how to choose a ccp_alpha based on validation scores.">

.. only:: html

  .. image:: /auto_examples/tree/images/thumb/sphx_glr_plot_cost_complexity_pruning_thumb.png
    :alt:

  :doc:`/auto_examples/tree/plot_cost_complexity_pruning`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Post pruning decision trees with cost complexity pruning</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The decision tree structure can be analysed to gain further insight on the relation between the features and the target to predict. In this example, we show how to retrieve:">

.. only:: html

  .. image:: /auto_examples/tree/images/thumb/sphx_glr_plot_unveil_tree_structure_thumb.png
    :alt:

  :doc:`/auto_examples/tree/plot_unveil_tree_structure`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Understanding the decision tree structure</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /auto_examples/tree/plot_tree_regression
   /auto_examples/tree/plot_iris_dtc
   /auto_examples/tree/plot_cost_complexity_pruning
   /auto_examples/tree/plot_unveil_tree_structure

