Uncertainty sampling is presented as the core active learning strategy for making a model smarter by sending humans only the items the model is least sure about. The chapter explains why this is more useful than random sampling: uncertain examples are the ones most likely to improve the model when labeled, while over-sampling already easy cases adds little value. It also emphasizes that uncertainty is not always straightforward to interpret, especially beyond simple binary tasks, so choosing the right measure depends on the data, the model, and the goal of the system.
The chapter then walks through the main ways to turn prediction scores into uncertainty values. It begins with understanding probability outputs, especially softmax, and warns that confidence scores can lose important information depending on how they are produced. It introduces least confidence, margin of confidence, ratio of confidence, and entropy-based sampling, showing how each scores items differently: some focus only on the top prediction, some compare the top two, and entropy considers the full distribution. The chapter highlights that these methods can behave differently with multiple labels, and that some are more sensitive than others to the shape and scaling of model outputs.
Next, the chapter broadens the view to different model families and practical workflow decisions. It explains how uncertainty can be estimated for neural networks, logistic regression, SVMs, Bayesian models, decision trees, random forests, and ensembles, including repeated predictions through techniques like Monte Carlo dropout. It also discusses how many items to send for annotation per iteration, how to avoid sampling only one narrow region of the data space, and how to evaluate success using both model metrics and human-labeling cost. The chapter closes by stressing careful experimental design: keep test and validation data separate from the active learning pool, compare against random sampling, and stop when gains begin to level off.
How softmax creates probability distributions. A linear activation function is used on the output layer, creating model scores (logits) that are then converted to probability distributions via softmax.
Uncertainty sampling is an active learning strategy that oversamples unlabeled items that are closer to the decision boundary (and sometimes to one another), and are therefore more likely to get a human label that results in a change in that decision boundary.
Example of low entropy (left) and high entropy (right). High entropy occurs when the probabilities are most like one another and there is the most surprise in any one prediction from the distribution. Entropy is sometimes a little counterintuitive, because the left graph has the most variability and three highly unlikely events. Those three unlikely events, however, are more than canceled by the one highly likely event. Four events at around equal likelihood will have greater total entropy, even if the three rarer events would have greater information on the rare times that they occur.
Uncertainty sampling from different supervised machine learning algorithms. Top left: The decision boundary from a support vector machine (SVM). A discriminative learner, like a neural model, attempts to find a way to divide the data optimally. Unlike neural classifiers, SVMs are also trying to maximize the width of the boundary. This is how an SVM decides which of multiple possible central lines is the best division: it has the widest boundary. Note that the distance from the divider (the hyperplane for SVMs) is from the far side of the divider, not the middle line. Top right: A potential Bayesian model. This model is a generative supervised learning model, trying to model the distribution of each label rather than model the boundary between them. The confidence on a per-label basis can be read directly as a probability of being that label. Bottom left: The division that a decision tree might provide, dividing and recursively subdividing the data one feature at time. The confidence is defined by the percentage of a label in the final bucket (leaf), The bottom-left leaf, for example, has one Label A and three Label Bs, so a prediction in that leaf would be 25% confidence in Label A and 75% confidence in Label B. Decision trees are sensitive to how far you let them divide—they could keep dividing to leaves of one item—so probabilities tend not to be reliable. Bottom right: An ensemble of decision trees, of which the most well-known variant is a random forest. Multiple decision trees are trained. The different trees are usually achieved by training on different subsets of the data and/or features. The confidence in a label can be the percentage of times an item was predicted across all models or the average confidence across all predictions.
SVM projecting our example 2D dataset (top) into 3D (bottom) so that a linear plane can separate the two sets of labels: Label A is above the plane, and Label B is below the plane. The sampled items are the least distance from the plane. If you want to learn from some of the important early active learning literature, you need to understand how SVMs work at this high level.
An ensemble model that combines predictions from different types of machine learning algorithms: neural models, SVMs, Bayesian models, and decision trees (decision forest). The predictions can be combined in various ways (max, average, and so on) to find the joint uncertainty of each unlabeled item.
Applying dropout to a model to get multiple predictions for a single item. In each prediction, a random set of neurons is dropped (ignored), resulting in different confidences and (possibly) different predicted labels. Then the uncertainty can be calculated as the variation across all predictions: the higher the disagreement, the more uncertainty. This approach to getting multiple predictions from a single model is known as Monte Carlo dropouts.
Differences between aleatoric and epistemic uncertainty, according to the definitions that are most widely used in machine learning literature. The first highlighted item is near the decision boundary of all five predictions, so it has high epistemic uncertainty, but the decision boundaries are clustered together, so it has low aleatoric uncertainty. The second highlighted item has low epistemic uncertainty because it is not near most decision boundaries, but its distance from the decision boundaries has a large amount of variation, so it has high aleatoric uncertainty. The final item is near the average decision boundary and has great variance in the distance between all boundaries, so it has high uncertainty for both types.
A selection of uncertain items that are all from the same region of the feature space, and therefore lack diversity
A heat map of the four main uncertainty sampling algorithms and the areas that they sample for a three-label problem. In this example, each dot is an item with a different label, and the heat of each pixel is the uncertainty. The hottest (most uncertain) pixels are the lightest pixels (the red pixels, if you’re viewing in color). Top left is least confidence sampling, top right is margin of confidence sampling, bottom left is ratio sampling, and bottom right is entropy-based sampling. The main takeaway is that margin of confidence and ratio sample some items that have only pairwise confusion and entropy maximizes for confusion among all labels.
A comparison of methods. The four left images show that a lot of the uncertainty space for margin of confidence and ratio is between two of the labels, which is ignored entirely by entropy because it is not ambiguous for the third label. The four right images show that especially in more complicated tasks, the items that will be sampled by different uncertainty sampling algorithms will be different.1
Uncertainty sampling cheat sheet
Summary
- Four common algorithms are used for uncertainty sampling: least confidence, margin of confidence, ratio of confidence, and entropy. These algorithms can help you understand the different kinds of “known unknowns” in your models.
- You can get different samples from each type of uncertainty sampling algorithm. Understanding why will help you decide which one is the best way to measure uncertainty in your models.
- Different types of scores are output by different supervised machine learning algorithms, including neural models, Bayesian models, SVMs, and decision trees. Understanding each score will help you interpret them for uncertainty.
- Ensemble methods and dropouts can be used to create multiple predictions for the same item. You can calculate uncertainty by looking at variation across the predictions from different models.
- There is a trade-off between getting more annotations within each active learning cycle and getting fewer annotations with more cycles. Understanding the trade-offs will let you pick the right number of cycles and size of each cycle when using uncertainty sampling.
- You may want to create different kinds of validation data to evaluate different parts of your system. Understanding the different types of validation data will let you choose the right one to tune each component.
- The right testing framework will help you calculate the accuracy of your system, ensuring that you are measuring performance increases correctly and not inadvertently biasing your data.
Human-in-the-Loop Machine Learning ebook for free