liveBook · Manning

Golden rule

As explained in Grokking Machine Learning

The model-evaluation rule that testing data must not be used to train a model or make decisions about its model or hyperparameters.

The golden rule protects honest model evaluation: use training data to train the model, and never use testing data for training or for decisions about model hyperparameters. section 4.2

Breaking the rule can cause overfitting that remains invisible during development. A model may look excellent yet fail on a secret dataset, especially when testing data was used accidentally. section 4.2

Choosing model complexity

Compare models using testing error without training on the testing set. For degree-1, degree-2, and degree-10 models, testing error first falls and then rises; the degree-2 model is preferred because it has low testing error. section 4.2

Figure 4.4 We can use this table to decide how complex we want our model. The columns represent the three models of degree 1, 2, and 10. The rows represent the training and the testing error. The solid circles are the training set, and the white triangles are the testing set. The errors at each point can be seen as the vertical lines from the point to the curve. The error of each model is the mean absolute error given by the average of these vertical lengths. Notice that the training error goes down as the complexity of the model increases. However, the testing error goes down and then back up as the complexity increases. From this table, we conclude that out of these three models, the best one is model 2, because it gives us a low testing error.

Use the figure to compare training and testing errors as model complexity changes. section 4.2

How Grokking Machine Learning covers it

How deep it goes
Defines the separation rule and illustrates its consequences, but stops short of a detailed testing workflow.
Examples
Uses secret-dataset failures and degree-1, degree-2, and degree-10 models to show why testing error matters.
What it assumes
Assumes a dataset split into training and testing data and introduces the restriction governing their use.
What you can do after
Apply it by reserving testing data for final evaluation rather than training or hyperparameter decisions.
How it connects
Connects training data, testing data, hyperparameters, overfitting, model complexity, and testing error.

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.