Özer Cem KELAHMETKELAHMET
AI Simulations · Learning methods

Active learning with uncertainty sampling: least confidence, margin and entropy compared

Labels cost money, so active learning lets the model choose what to label next. Uncertainty sampling asks for the examples it is least sure about, but there are three common ways to measure being unsure, and they do not agree. Here you compare them on real predictions.

Download Markdown

Interactive simulation. It needs JavaScript; the text below explains what it shows.

What you are looking at

A logistic regression was trained with scikit-learn on only six labelled flowers from the iris dataset, two of each species. It then predicted the species of 24 unlabelled flowers. For each one the table keeps its two highest class probabilities, p1 and p2 (the third is what is left), and whether its guess is actually right, which in real life you would only learn after a human labels it. All numbers come from that run.

On the chart each flower sits at its top probability. The solid curves show least confidence, which depends only on p1, and the entropy a flower would have if the rest of its probability were split evenly between the other two species. The fitted markers are each flower's uncertainty under the measure you picked, and the dashed line is the bar above which a flower goes to the annotator. The dots at 1 and 0 mark right and wrong guesses. The bars show the same uncertainty flower by flower.

The algorithm

Pool-based active learning repeats one loop: train on what is labelled, score every unlabelled example, send the most informative ones to a human, add their labels and train again. modAL, a scikit-learn-style active learning library, ships the three classic uncertainty scores:

  1. Least confidence: 1 − p(1), one minus the top probability. modAL calls this classifier uncertainty. It ignores how the remaining probability is spread.
  2. Margin: p(1) − p(2), the gap between the top two classes; a small margin means the model is torn between two answers. Here it is turned into an uncertainty, 1 − margin.
  3. Entropy: −Σ p ln p over all classes, highest when every class is equally likely.

To put them on one scale the simulation divides least confidence by its maximum, 2/3, and entropy by ln 3, so all three run from 0 (certain) to 1 (as unsure as three classes allow). Libraries usually query the top-k examples by score; a bar on the score does the same job and makes the size of the batch visible.

Worked example

Take flower 6: p = 0.611, 0.202, 0.187. Least confidence is 1.5 × (1 − 0.611) = 0.584. The margin is 0.611 − 0.202 = 0.409, an uncertainty of 0.591. Its entropy is −(0.611 ln 0.611 + 0.202 ln 0.202 + 0.187 ln 0.187) / ln 3 = 0.853, one of the highest in the pool, because the leftover probability is shared evenly. Now flower 10: p = 0.504, 0.465, 0.031. Its margin uncertainty is 0.961, but its entropy is only 0.736, because the third species is all but ruled out. With entropy and a bar of 0.75, seven flowers go to the annotator (6, 9, 12, 13, 19, 21 and 24). Two of the three wrong guesses are among them, an error rate of 28.6% in the queried set against 12.5% in the pool. The most uncertain flower is 21 by least confidence and by margin, but 13 by entropy.

Things to try

  • Switch to margin (1) at the same bar. Eight flowers are sent and all three wrong guesses are among them, an error rate of 37.5%. All three mistakes are versicolor flowers taken for virginica, the two species the dataset's description says are not linearly separable, and margin is built to find exactly that kind of two-way confusion.
  • Switch to least confidence (0). At 0.75 only flower 21 passes. Lower the bar to 0.60: seven flowers, all three errors caught, 42.9% of the queried set wrong.
  • With entropy, lower the bar to 0.50: fifteen flowers are sent and all three errors are caught, but the error rate in the batch falls to 20%: you pay for labels the model did not need.
  • Read the correlation of margin and entropy, 0.924. Highly correlated measures can still rank the top of the list differently, and the top is all that gets labelled.
  • Paste your own model's two highest probabilities for a pool and see which examples each measure would buy.

How it works in real systems

Uncertainty sampling is the simplest and most used active learning strategy, but it has known traps. It trusts the model's probabilities, so a badly calibrated model asks the wrong questions. It can pick many near-duplicates from the same confused region in one batch, which is why batch methods add diversity, for example by clustering candidates or sampling from embeddings. And it ignores how representative an example is: the most uncertain one is sometimes just noise. The same scores drive data selection for large models today, from choosing which model outputs go to human raters to picking hard prompts for fine-tuning. When labels are cheap to guess instead of buy, the opposite move is pseudo-labelling the confident ones, shown in the pseudo-labelling simulation. For how probabilities turn into decisions see precision and recall against a threshold, and for the model used here see logistic regression.

Sources

Last updated Nov 24, 2026
Type to search.
    ↑↓ navigate↵ open