RegressionSample
Decision tree regression
Splits the input into intervals and predicts the average target in each.
Synthetic data, generated and trained in your browser.
Try this
- 01Use the Steps data at depth 2: the tree recovers the three levels almost exactly.
- 02Switch to Curve and raise depth to 8 with min leaf 1: the tree memorises the noise.
- 03Turn on the test split and find the depth where test R² peaks.
How it works
- 1Try every split point and keep the one that most reduces squared error.
- 2Repeat inside each side until the maximum depth or minimum leaf size is reached.
- 3Each leaf predicts the mean of its training points, giving a step-shaped curve.
What the controls teach
- Max depth
- How many times the data can be split. Each level can double the number of steps.
- Min samples per leaf
- The fewest points a leaf may hold. Larger values stop the tree fitting single points.
Use it when
- Non-linear, step-like relationships
- When you need explainable rules
Avoid it when
- Smooth trends (predictions are piecewise constant)
- Deep trees without a validation check