Overview

6 Applying active learning to different machine learning tasks

This chapter shows how active learning extends beyond simple image and document classification to more complex tasks where the model must identify objects, spans, pixels, or generated outputs. The main idea stays the same: use uncertainty and diversity to choose the most valuable items for human review, but define those concepts in a way that matches the real task. In practice, that means deciding whether the model should focus on whole images, specific objects, boundaries, spans, or labels, and making sure sampling reflects what actually matters in deployment.

For object detection and semantic segmentation, the chapter emphasizes separating label confidence from localization confidence, using metrics such as F-score, IoU, and mAP where appropriate. Uncertainty can come from softmax probabilities, ensembles, or Monte Carlo dropout, while diversity usually requires cropping or masking to keep the focus on the object or region of interest instead of the background. The same logic applies to representative and cluster-based sampling, but the book warns that these methods can be biased if training data and unlabeled data are encoded differently or if context and background dominate the representation.

The chapter then adapts these principles to sequence labeling, language generation, video, speech, and information retrieval. For sequence tasks, spans must be sampled with enough surrounding context, and uncertainty may need to include boundary tokens as well as the tokens inside the span. For language generation, evaluation is harder because there may be multiple valid outputs, so uncertainty is less straightforward, but diversity and transfer learning still help. Across all tasks, the recurring message is to align sampling, evaluation, and annotation design with the use case, stratify when needed to avoid bias, and choose how many examples to review based on annotation cost, task complexity, and the type of model errors that matter most.

An illustration of the problem of identifying uncertainty and diversity in object detection tasks. The object we care about—the bicycle—is a small percentage of the pixels in the bounding box that surrounds it. Even a modest amount of context is twice the number of pixels, and the image as a whole is 10 times the number of pixels of the bounding box. Therefore, if we tried to calculate uncertainty or diversity across the whole image, we would risk focusing on a lot of irrelevant information.
An example of IoU for measuring the accuracy of a bounding box. The accuracy is calculated as the area that intersects the predicted bounding box with the actual bounding box, divided by the area that is the union of the two boxes.
An example prediction heat map for an object, showing low variation (left) and high variation (right). The high variation is evidence of more uncertainty in the model; therefore, the right example is a good candidate for human evaluation. You can generate multiple predictions by using ensemble models, getting predictions from multiple models and changing the parameters, using a subset of features or a subset of items, or introducing random variation into your models in some other way. Within a single model, you can generate multiple predictions for a single item by using a dropout over a random selection of neurons for each prediction (known as Monte Carlo dropouts). You can also combine both methods: create an ensemble of models, and use dropouts for multiple predictions per model.
An example of an object—a bicycle—in an image in which 99% of the image is not the bicycle. The bicycle and immediate context captured by the dotted line should be enough for identifying that the object is a bicycle. With some strategies, such as representative sampling and clustering, we need to crop or mask the image to target these areas.
Stratifying by confidence: sampling an equal number of items at 0–10% confidence, 10–20% confidence, and so on up to 90–100% confidence. In this example, one item is sampled from each 10% confidence interval for label A. Stratifying by confidence helps most when you have a large number imbalance between labels.
An example of object detection using a polygon rather than a bounding box. You can use the same active learning methods for both bounding boxes and polygons, with the extra option to have a closer mask for a polygon.
An example of semantic segmentation in which every pixel is labeled. This kind of colored photograph is what a lot of semantic segmentation tools look like: a coloring-in exercise. We’ll cover those tools later in the book, especially in chapter 10. If you’re looking at this image in black and white, the contrasting shades of gray should give you a good idea of what it would look like in color. If the objects receive a label (the four trees are labeled separately, for example), the task is known as instance segmentation.
An example of stratified sampling by label applied to segmentation. For this example task, assume that we care about errors related to human and bicycle pixels more than we care about errors related to tree and sky pixels. Our active learning sample will consist of a 90:10 split: 90% will be the most confusing samples for the labels that we care about most, and 10% will be about the labels that we don’t care about. Note that the pixels bordering the sky and trees vastly outnumber the pixels bordering humans and bicycles, so stratified sampling helps us focus on the errors that we care about most. Therefore, your sampling strategy might diverge from your accuracy evaluation strategy, in which you can simply apply relative weights of 90% and 10% to high- or low-value errors. The uncertainty sampling metrics don’t lend themselves as easily to this kind of weighting, so unless you are confident enough in your statistics skills to tune your weighting strategy, use this stratification method.
Table 6.1 An example sequence labels: keyword detection and two types of named entities, diseases, and locations. Label B (beginning) is applied to the beginning of the span, and Label I (inside) is applied to the other words within the span, allowing us to unambiguously distinguish spans that are next to each other, such as “San Francisco” and “supermarket”. This process is called IOB tagging, in which O (outside) is the nonlabel. (O is omitted from this table for readability.)
Table 6.2 An example of location identification and confidence associated with each label. The table shows an error in that only “San” from “San Francisco” is a location, but “Francisco” was reasonably high confidence. So we want to make sure that we take into account information outside the predicted spans when calculating confidence.
Three ways to encode predicted spans for active learning: using one-hot encoding to encode each token as its own feature (top left); using a noncontextual vector (embedding) such as word2vec (top right); and using a contextual embedding such as BERT (bottom). You can also experiment with average pooling (avepool) in place of or in addition to maximum pooling (maxpool).
Table 6.3 An example of a full-sequence parse, showing POS tags (labels) such as nouns, verbs, adverbs (Adv), proper nouns (PRP), and so on

Summary

  • In many use cases, you want to identify or extract information within an image or document rather than label the entire image or document. The same active learning strategies can be applied to these use cases. Understanding the right strategy helps you understand the kinds of problems to which you can apply active learning and how to build the right strategy for your use case.
  • You need to crop or mask your images and documents to get the most out of some active learning strategies. The right cropping or masking strategy produces better samples for human review, and understanding when you need to crop or mask your items helps you select the right method for your use cases.
  • Active learning can be applied to many tasks beyond computer vision and NLP, including information retrieval, speech recognition, and videos. Understanding the broader landscape of active learning application areas will help you adapt any machine learning problem.
  • The number of items to select for human review in each iteration of advanced active learning is highly specific to your data. Understanding the right strategy for your data is important for deploying the most efficient human-in-the-loop machine learning systems for your problems.

FAQ

What is the main idea of applying active learning to different machine learning tasks?Active learning uses the same core ideas—uncertainty sampling and diversity sampling—but adapts them to the structure of each task. The main change is how you choose the items to sample, which depends on whether you are working with object detection, segmentation, sequence labeling, language generation, speech, video, or retrieval.
How does active learning differ for object detection compared with image classification?Object detection requires you to think about two things separately: the object label and the object’s location. So active learning should consider both label confidence and localization confidence, often using metrics such as F-score, IoU, or mAP depending on the use case.
Why is IoU important in active learning for object detection?IoU, or intersection over union, measures how well a predicted bounding box matches the true box. It is the standard metric for localization accuracy, and it is useful for deciding which predicted boxes are uncertain enough to send for human review.
How can uncertainty be estimated for localization in object detection?Since many object detection models mainly provide label confidence, localization uncertainty is often estimated using ensembles or Monte Carlo dropout. You generate multiple bounding-box predictions and measure how much they vary, for example by averaging IoU across predictions.
Why does diversity sampling often require cropping or masking in object detection and semantic segmentation?Because the background can dominate the features if you use the whole image. Cropping or masking helps ensure that clustering, representative sampling, or outlier detection focuses on the objects or pixels you actually care about rather than irrelevant context.
How is uncertainty sampling done for semantic segmentation?Semantic segmentation usually produces per-pixel probability distributions, so uncertainty can be calculated at the pixel level. A common approach is to use the average uncertainty of pixels near boundaries or the pixels relevant to the labels you care about most.
What is the best way to sample spans in sequence labeling tasks?For sequence labeling, uncertainty is usually calculated over token probabilities, then aggregated over spans. Diversity sampling should focus on the spans themselves, often using a window of surrounding context that matches the model’s context representation.
How should active learning be applied to language generation tasks?Language generation is harder because there is often no single correct answer. Uncertainty can come from variation across generated candidates, ensembles, or dropout, while diversity sampling usually follows the same principles as document-level labeling, with attention to domain coverage and real-world variation.
What role does stratified sampling play in active learning?Stratified sampling helps avoid bias when one label, confidence range, or object type dominates the dataset. Instead of sampling only the most frequent or easiest examples, you sample across confidence bands, labels, or other meaningful groups to keep the training data balanced.
How do you decide how many samples to send for human review?You should base the number on the annotation cost, the task type, and whether partially annotated data is useful. In complex tasks like segmentation, a smaller number of high-value samples may be better, while tasks like text labeling may allow many more items per iteration.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Human-in-the-Loop Machine Learning Human-in-the-Loop Machine Learning ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Human-in-the-Loop Machine Learning Human-in-the-Loop Machine Learning ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Human-in-the-Loop Machine Learning Human-in-the-Loop Machine Learning ebook for free