# Top-k error percentage

Subject: Deep Learning

Exam: MT2

Reader: https://deep-learning-study-room.vercel.app/#mt2/formulas/48

Canonical: https://deep-learning-study-room.vercel.app/read/dl/mt2/formulas/48/

Top-k error counts examples whose correct class is absent from the highest-scoring k predictions. Success counts must not be added twice.



$$
E_k=\frac{N-C_k}{N}\times100\%
$$



## Top-1 and top-5 error: what an ImageNet result means

**Top-1 prediction** is the class with the highest score. A top-1 mistake occurs when that class is wrong. **Top-5 prediction** is the list of the five highest-scoring classes. A top-5 mistake occurs only when the correct class is absent from that list. It is not the average error of five separate models.

For an image of a cat, the ordered list dog, cat, fox, horse, bird is a top-1 error but a top-5 success. The ordered list dog, fox, horse, bird, car is an error under both measures.

**Question (practice, 2 marks). A classifier evaluates 100 images. The correct class is ranked first for 78 images and appears somewhere in the first five positions for 92 images. Calculate top-1 error and top-5 error.**

### Given

Total images = 100; top-1 successes = 78; top-5 successes = 92. The 78 first-place successes are already included in the 92 top-five successes.

### To find

The percentage of mistakes under each rule.

### Formula — which one and why

Subtract successful images from the total to obtain mistakes. Divide mistakes by the total and multiply by 100 to express a percentage.



$$
E_k=\frac{N-C_k}{N}\times100\%
$$



N means total evaluated images; C\_k means images whose correct class appears among the top k predictions.

### Solution — step by step

**Step 1: top-1 mistakes.** 100 − 78 = 22.

**Step 2: top-1 error percentage.**



$$
E_1=\frac{22}{100}\times100\%=22\%
$$



**Step 3: top-5 mistakes.** 100 − 92 = 8.

**Step 4: top-5 error percentage.**



$$
E_5=\frac{8}{100}\times100\%=8\%
$$



**Final answer:** top-1 error = 22%; top-5 error = 8%. A broader acceptable list makes top-5 error no greater than top-1 error for the same evaluated predictions.

**Yaad rakho:** top-five mein sahi naam mil gaya toh top-five success.
