Decision Tree Regression
In this example, we demonstrate the effect of changing the maximum depth of a decision tree on how it fits to the data. We perform this once on a 1D regression task and once on a multi-output regression task.
# Authors: The scikit-learn developers
# SPDX-License-Identifier: BSD-3-Clause
Decision Tree on a 1D Regression Task
Here we fit a tree on a 1D regression task.
The decision trees is used to fit a sine curve with addition noisy observation. As a result, it learns local linear regressions approximating the sine curve.
We can see that if the maximum depth of the tree (controlled by the
max_depth parameter) is set too high, the decision trees learn too fine
details of the training data and learn from the noise, i.e. they overfit.

