Skip to content
Glacius
OptimizationConcept reference

Empirical objectives

An empirical objective is the average stated loss over all examples in a fixed dataset.

On this page 7 sections
  1. Overview
  2. A loss for the whole dataset
  3. Loss first, average second
  4. State the convention
  5. Key takeaway
  6. Sources & further reading
  7. Concept connections

01A loss for the whole dataset#

An empirical objective summarizes how a model performs on a fixed dataset. First calculate a loss for every example using the same rule. Then average those losses. Changing the parameters changes the losses and therefore the objective.

At one parameter setting, three examples have losses 1,4,71,4,7. Their total is 1212, and the dataset contains three examples. The empirical average is 44.

Three fixed examples have losses 1,4,7. Their sum is 12; their empirical mean is 4. The last bar shows the average on the same loss scale.Three fixed examples have losses 1,4,7. Their sum is 12; their empirical mean is 4. The last bar shows the average on the same loss scale.
Figure 1Three fixed examples have losses 1,4,7. Their sum is 12; their empirical mean is 4. The last bar shows the average on the same loss scale.
Link to this figure ↗Download SVGDownload PNG

Writing the parameter vector as θ\theta and example ii's loss as ℓi(θ)\ell_i(\theta) gives

J(θ)=1n∑i=1nℓi(θ).J(\theta)=\frac1n\sum_{i=1}^{n}\ell_i(\theta).

Each example contributes once, even if several losses have the same value.

Check your reasoning

Losses: 0,3,3,60, 3, 3, 6. Find their empirical average.

Show answer and explanation
3

Sum 1212 over 44 examples: 33.

02Loss first, average second#

Suppose predictions are (0,3)(0,3) and targets are (2,1)(2,1). The residuals are −2-2 and 22. Under half-squared loss, each example contributes 22, giving mean loss 22.

Averaging residuals first would give zero, then squaring would give zero. That would hide both errors. The order of operations is part of the objective's definition.

Check your reasoning

Targets: (1,0)(1, 0); predictions: (4,2)(4, 2). Each loss is (y^−y)2/2(\hat y-y)^2/2. Find the mean loss.

Show answer and explanation
3.25

Per-example losses: 4.5, 2. Their average is 3.253.25.

03State the convention#

Squared loss (y^−y)2(\hat y-y)^2 and half-squared loss (y^−y)2/2(\hat y-y)^2/2 differ by a factor of two. Summed loss and mean loss differ by the number of examples. Read the stated convention before calculating.

Repeating the entire dataset leaves its mean loss unchanged: both numerator and denominator double. Repeating only its hardest example changes that example's weight and usually changes the mean.

Check your reasoning

Losses: 0,0,4,4,20, 0, 4, 4, 2. A draft divides the sum by 3 distinct losses. Correct the average.

Show answer and explanation
2

Sum 1010 over 55 examples: 22.

A zero-loss example still belongs in the denominator. Averaging batch averages equally works only when the batches have equal size; otherwise weight each average by its number of examples.

This objective describes the observed dataset. Expected loss describes a probability model for new examples. Treating the empirical average as an estimate of that expectation requires assumptions about how the data were collected. Model evaluation checks that connection separately.

Key takeaway

Compute every loss with its stated convention, sum them and divide by the actual example count.

  • Form an average per-example loss over a fixed dataset.

Sources & further reading

  1. [1]
  2. [2]
    Stanford CS229, Main Notes, Part I §1 ↗cs229.stanford.edu · Article
  3. [3]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Empirical objectives.” Math behind ML. /learn/o-empirical