liveBook · Manning

Mean squared error

As explained in Grokking Machine Learning

A regression error metric equal to the average squared difference between observed and predicted target values.

Mean squared error (MSE) measures the average squared difference between observed and predicted values. Squaring makes each error positive; averaging makes errors comparable across datasets with different numbers of points. section 3.4

Choosing an age cutoff

For a regression tree predicting app engagement from user age, a cutoff of 35 gives an MSE of 1.983, the smallest among the cutoffs shown. The tree uses MSE to choose its split. section 9.6

Table 9.7 The nine possible ways to split the dataset by age using a cutoff. Each cutoff splits the dataset into two smaller datasets, and for each of these two, the prediction is given by the average of the labels. The mean square error (MSE) is calculated as the average of the squares of the differences between the labels and the prediction. Notice that the splitting with the smallest MSE is obtained with a cutoff of 35. This gives us the root node in our decision tree. (view table figure)

Cutoff

Labels left set

Labels right set

Prediction left set

Prediction right set

MSE

0

{}

{7,5,7,1,2,1,5,4}

None

4.0

5.25

15

{7}

{5,7,1,2,1,5,4}

7.0

3.571

3.964

25

{7,5}

{7,1,2,1,5,4}

6.0

3.333

3.917

35

{7,5,7}

{1,2,1,5,4}

6.333

2.6

1.983

45

{7,5,7,1}

{2,1,5,4}

5.0

3.0

4.25

55

{7,5,7,1,2}

{1,5,4}

4.4

3.333

4.983

65

{7,5,7,1,2,1}

{5,4}

3.833

4.5

5.167

75

{7,5,7,1,2,1,5}

{4}

4.0

4.0

5.25

100

{7,5,7,1,2,1,5,4}

{}

4.0

none

5.25

Compare the candidate age cutoffs, their group predictions, and their MSE values. section 9.6

How Grokking Machine Learning covers it

How deep it goes
Defines MSE as an average of squared prediction differences and works through its use to compare tree splits.
Examples
Compares age-based splits for predicting app engagement and illustrates squared distances from points to a regression line.
What you can do after
Evaluate regression errors and compare candidate splits using average squared prediction differences.
How it connects
Connects MSE to linear regression, regression decision trees, mean absolute error, and root mean square error.

Also explained in

Compare how 13 books explain mean squared error →

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.