Active Learning
Active learning lets a model choose which unlabeled samples people label next, reaching a target accuracy with fewer labels. Query strategies and code.
Active learning is a machine learning approach in which the model chooses which unlabeled examples a person should label next. Instead of labeling a random sample of the data, a team trains a model on a small labeled set, uses it to score a large pool of unlabeled examples, sends the most informative ones to annotators, retrains on the enlarged set, and repeats. The person who supplies labels is called the oracle. The goal is to reach a target accuracy with as few labels as possible, which matters most when labeling needs experts, such as radiologists reading scans, or when the pool is far too large to label in full, such as the video an autonomous vehicle fleet records every day.
How the Active Learning Loop Works#
Computer vision projects usually run pool-based active learning, where a fixed collection of unlabeled images waits to be scored. Each round has four steps:
- Train: Fit a model, such as an object detection model, on the labeled examples collected so far.
- Score: Run the model over the unlabeled pool and give each example an informativeness score.
- Query: Send the top-scoring batch to annotators for data labeling.
- Update: Add the new labels to the training data and retrain.
The loop ends when the labeling budget runs out or accuracy on a fixed validation set stops improving. Comparing each round against a model trained on the same number of randomly chosen labels shows whether the selection is helping.
Query Strategies#
The query strategy decides what counts as informative:
- Uncertainty sampling: Picks the examples the model is least sure about, measured by the lowest top-class confidence, the smallest margin between the top two classes, or the highest entropy of the predicted class distribution.
- Query by committee: Trains several models and picks the examples they disagree on most. Monte Carlo dropout gives a cheap committee from a single network.
- Diversity sampling: Picks examples that cover the embedding space, so a batch does not fill up with near-duplicates such as consecutive video frames. The core-set approach frames batch selection this way after finding that many uncertainty heuristics were not effective for CNNs in the batch setting.
- Hybrid strategies: Combine both signals. BADGE picks examples that are both uncertain and diverse in a gradient embedding space without hand-tuned weights.
Detectors produce many boxes per image, so their box scores have to be combined into one score per image, for example by averaging the confidence of every detection. The script below ranks a small pool by mean detection confidence with a pretrained YOLO26 model and queries the least confident image first:
from ultralytics import YOLO
# Model trained on the current labeled set
model = YOLO("yolo26n.pt")
# Unlabeled pool, usually thousands of images
pool = ["https://ultralytics.com/images/bus.jpg", "https://ultralytics.com/images/zidane.jpg"]
results = model(pool, conf=0.1)
# Least-confidence sampling: score each image by its mean detection confidence
scores = {}
for image, result in zip(pool, results):
if len(result.boxes):
scores[image] = result.boxes.conf.mean().item()
# Query the lowest-scoring images first, within a labeling budget of one image
query = sorted(scores, key=scores.get)[:1]
print(f"Label next: {query}")The low conf=0.1 threshold keeps weak detections in the score, since those are the boxes the model is unsure about. The Ultralytics Platform annotation editor closes the rest of the loop: its Smart mode loads your own fine-tuned YOLO models, so each retrained model pre-labels the next queried batch for annotators to correct.
Practical Pitfalls#
- Cold start: Uncertainty scores from a model trained on a few dozen examples are unreliable, so the first rounds often use random or diversity-based selection.
- Redundant batches: Picking the k most uncertain images independently tends to return clusters of near-identical images, which is the problem diversity and hybrid strategies address.
- Sampling bias: The labeled set drifts away from the real data distribution because it over-represents hard cases, so validation and test sets are drawn at random from the full pool to keep their scores unbiased.
- Outliers: Corrupt, blurry, or out-of-domain images look uncertain to every model and can waste labeling budget unless they are filtered out.
Active Learning vs. Related Terms#
- Semi-supervised learning: Also uses unlabeled data, but the model assigns pseudo-labels to its own confident predictions instead of asking a person about its uncertain ones. The two are often combined.
- Curriculum learning: Orders already-labeled examples from easy to hard during training. Active learning decides which examples get labeled at all.
- Hard negative mining: Picks the labeled negatives that the model gets most wrong and trains on them more. It works on existing labels and adds no new ones.
- Data flywheel: A production loop in which deployed models surface new data that improves the next model. Active learning is a common selection step inside it.










