liveBook · Manning

DecisionTreeRegressor

As explained in Grokking Machine Learning

A scikit-learn estimator class that fits regression decision trees to numerical targets.

DecisionTreeRegressor predicts numerical targets by repeatedly asking cutoff questions. Each split divides the data, assigns each side its average target, and chooses the cutoff with the lowest mean squared error. section 9.6

Predicting app engagement from age

For eight users, age predicts weekly app-opening days. Testing possible age cutoffs selects 35 because it produces the smallest MSE. Setting max_depth=2 creates splits at 35, 15, and 65, with leaf predictions of 7, 6, 1.33, and 4.5. section 9.6

Table 9.6 A small dataset with eight users, their age, and their engagement with our app. The engagement is measured in the number of days when they opened the app in one week. (view table figure)

Age

Engagement

10

7

20

5

30

7

40

1

50

2

60

1

70

5

80

4

Inspect the eight-user age and engagement dataset used to build the regression tree. section 9.6

How Grokking Machine Learning covers it

How deep it goes
Explains cutoff testing, mean squared error, recursive splitting, depth control, and leaf predictions.
Examples
Uses eight users’ ages and weekly app engagement, with cutoffs at 15, 35, and 65.
What it assumes
Assumes feature and label arrays, while introducing regression-tree splitting and mean squared error through a small dataset.
What you can do after
Apply it via scikit-learn by fitting DecisionTreeRegressor(max_depth=2) to feature and label arrays.
How it connects
Connects decision trees with regression, mean squared error, recursive partitioning, and leaf-node averages.

Also explained in

Compare how 2 books explain DecisionTreeRegressor →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning. The section links point to the parts of the book it draws on.