The Modern Mathematics of Deep Learningexplained for non-mathematicians

Risk on a separate test sample

Penguin learning project

The project uses 342 complete Palmer penguin records: 240 training-pool and 102 held-out rows. The selected training rows determine feature scaling and model parameters. Source CSV

This project trains weights with softmax, unlike the homepage lab, which uses nearest species averages. Same penguin measurements; different classification methods. Predictions can differ.

Classification predicts three species; Ridge predicts body mass in grams using the same observations. These are separate models. Training predictions feed the objective; 102 separate test predictions never update the weights.

Risk and assessment · Distinguish loss on a sample from expected loss.

The fitted rule is evaluated on 102 held-out observations, not used for fitting.

Held-out evaluation

Input
102 · #58: 40.6 mm, 193 mm
Output
Known answer: Adélie; Prediction: Adélie · [≈0.7383, ≈0.2444, ≈0.01737]; Held-out mean loss: ≈0.1639 (cross-entropy); Correct: 99/102

Project operation

The project calculation uses these records; the source formula and example follow below. Code edits run locally; project settings travel between pages.

Prediction → Held-out evaluation → Held-out evaluation

Project input

Showing first three entries; the operation receives the complete array. Rounded preview; the operation uses full precision.

input.task · Project settings or constant
classification
input.predictions · Prediction
[Species: Adélie · Probabilities: [≈0.7383, ≈0.2444, ≈0.01737], Species: Adélie · Probabilities: [≈0.533, ≈0.2223, ≈0.2447], Species: Gentoo · Probabilities: [≈0.0001477, ≈0.001447, ≈0.9984]] … (102 entries)
input.targets · Observations
[0, 0, 2] … (102 entries)
input.rows · Observations
[Species: Adélie · Mass (g): 3800, Species: Adélie · Mass (g): 4000, Species: Gentoo · Mass (g): 5250] … (102 entries)

Result

Mean loss: ≈0.1639 · Correct: 99 · Total: 102

Used in these source sections: 1.3 The questions ahead

Train a rule on sample s, then average its losses on a separate sample s-tilde.

The toy rule always predicts 0; the separate test labels are [0,1,1].

A separate test sample can estimate performance on new data.

Source formula example

R^s~(fs)\widehat{\mathcal R}_{\tilde s}(f_s)

illustration · This finite test mean is not generally equal to population risk. The toy test data are fixed and invented.

Symbols

fsf_s
A rule learned from the training sample s.
 s~s
A separate test sample.

Source formula example

This source example uses its own inputs and assumptions. Editing it does not change the project.

Edit a value or the code, then run the example. This is a finite demonstration, not a proof of the paper’s theorem.

This example’s data flow

You choose

  • input.prediction = 0

Initial values in code

  • testLabels = [0, 1, 1]

Calculated here

Result expression: { testLabels, prediction, losses, testRisk: losses.reduce((a, b) => a + b, 0) / losses.length, }

  • prediction = input.prediction Uses: input.prediction
  • losses = testLabels.map((label) => (prediction === label ? 0 : 1)) Uses: testLabels, prediction

Returns

Example result
testLabels
array (3 items): [0, 1, 1]
prediction
0
losses
array (3 items): [0, 1, 1]
testRisk
≈0.6667

Read numbers from input and return the result. JavaScript basics.

Result

Enable JavaScript to run this example.

Technical statement

The source describes independent test examples drawn from the same population as the training data. The code evaluates a supplied rule on a fixed toy test sample; it does not train the rule or simulate sampling.

Source: Test sample risk