Surprisal loss
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.
Individual losses · Give one observed example a loss score.
Project predictions and known answers produce losses. Classification uses cross-entropy and α/2 times squared non-bias weights; Ridge uses normalized-mass MSE and α times all squared coefficients, including the intercept.
Loss
- Input
- Training: 12 Prediction
- Output
- [≈0.005482, ≈1.012, ≈0.1422] … (12 entries) · Mean training loss: ≈0.228 (cross-entropy)
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 → Loss → Mean training loss
Project input
Showing first three entries; the operation receives the complete array. Rounded preview; the operation uses full precision.
input.task· Project settings or constantclassificationinput.predictions· Prediction[Species: Adélie · Probabilities: [≈0.9945, ≈0.005412, ≈0.00005477], Species: Adélie · Probabilities: [≈0.6338, ≈0.3635, ≈0.002677], Species: Gentoo · Probabilities: [≈0.1023, ≈0.03028, ≈0.8674]] … (12 entries)input.targets· Observations[0, 1, 2] … (12 entries)
Result
[≈0.005482, ≈1.012, ≈0.1422] … (12 entries)
Used in these source sections: 1.2 Learning from examples
The surprisal of an observed value z is −log(f(z)), where f(z) is its positive density.
This loss appears in maximum likelihood estimation.
Source formula example
illustration · Density values need not be probabilities at individual points; zero density gives infinite loss and is not used in this finite computation.
Symbols
- A probability density.
- An observed value.
- The surprisal loss.
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
Code changed. Reset to restore this example’s data flow.
Initial values in code
density=0.5
Calculated here
Result expression: { density, loss: -Math.log(density) }
Returns
density- 0.5
loss- ≈0.6931
Read numbers from input and return the result. JavaScript basics.
Result
Technical statement
The numerical values are invented. Density values need not be probabilities at individual points; zero density gives infinite loss and is not used in this finite computation.
Source: Inline notation