Overview

2 Getting started with human-in-the-loop machine learning

The chapter argues that the best way to begin a human-in-the-loop machine learning project is with a simple, workable minimum viable system that you can improve through iteration. Using a disaster-related news headline classification task as the running example, it emphasizes that real-world datasets are usually not truly random or representative, because they have already been shaped by prior sampling and filtering decisions. Rather than trusting existing datasets as-is, the chapter encourages making assumptions explicit, starting with a small but functional pipeline, and learning from the data as you build.

A central idea is that active learning should guide which items humans review next. The chapter explains two practical signals for selecting useful examples: low model confidence, which highlights items the model is uncertain about, and outliers, which surface novel or unusual items that may be missing from the current training set. It describes an iterative workflow in which a random evaluation set is collected first, an initial training set is labeled, and then new items are chosen by a mix of low-confidence sampling, random sampling, and outlier detection. This strategy helps improve model performance while also increasing dataset diversity and guarding against blind spots.

The chapter also covers the supporting machinery needed to make the loop work: a simple annotation interface, basic data management practices, and a lightweight text classifier implemented in PyTorch. It stresses that the interface should be efficient for annotators, with clear instructions, hotkeys, and a back option, while the data should be stored carefully, redundantly, and without overwriting original files. For evaluation, it recommends using held-out data collected early, and judging progress with F-score and AUC rather than raw accuracy, since the labels are imbalanced. Overall, the chapter’s message is that in early human-in-the-loop systems, getting the data, annotation flow, and iteration process right matters more than optimizing the model architecture first.

The architecture of your first human-in-the-loop machine learning system
The iterative process in your first human-in-the-loop machine learning system. Initially (top), you are annotating a random sample of unlabeled items to set aside as your evaluation data. Then you are labeling the first items to be used for training data (middle), also starting with a random selection. After this point, you start using active learning (bottom) to sample items that are low-confidence or outliers.
The command-line interface annotation tool for the example in this chapter

Summary

  • A simple human-in-the-loop machine learning system can cover the entire cycle, from sampling unlabeled data to updating the model. This approach lets you get started quickly with a complete MVP system that you can build out as needed.
  • Two simple active learning strategies are easy to implement: sampling the least most confident items from predictions and sampling outliers. Understanding the basic goals of each of these strategies will help you dive deeper into uncertainty and diversity sampling later in this book.
  • A simple command-line interface can allow humans to annotate data efficiently. Even a simple text-only interface can be efficient if it is built according to general human–computer interaction principles.
  • Good data management, such as creating evaluation data as the first task, is important to get right. If you don’t get your evaluation data right, you may never know how accurate your model is.
  • Retraining a machine learning model with newly annotated data at regular iterations shows that your model gets more accurate over time. If designed correctly, the active learning iterations are naturally self-correcting, with overfitting in one iteration corrected by the sampling strategy in the following iterations.

FAQ

What is the main goal of this chapter?The chapter’s main goal is to help you build your first human-in-the-loop machine learning MVP. It introduces a simple, functional system first, then shows how to iterate by improving data sampling, annotation, training, and evaluation.
Why should you start with a simple system instead of trying to build the best model right away?Starting simple lets you ship a minimum viable product quickly and learn from real feedback. That feedback tells you which parts of the system matter most, so you can improve the right components first instead of over-engineering too early.
What does “active learning” mean in this chapter?Active learning is the process of selecting the most useful data for human review. In this chapter, that means choosing unlabeled items that are likely to be informative, such as low-confidence predictions or outliers.
Why does the book warn against “hacktive learning”?“Hacktive learning” means using ad hoc sampling methods instead of a principled active learning strategy. The book argues that even if you are moving quickly, it is better to get the fundamentals right so your sampling choices actually improve the model.
Why should evaluation data be collected before training data?Evaluation data should be collected first so it remains a truly random held-out sample. If you collect it later, after confidence-based or outlier sampling has begun, the evaluation set can become biased and give you misleading accuracy results.
How does confidence ranking help with active learning?Confidence ranking helps identify examples the model is most uncertain about. The chapter recommends sampling items with the lowest confidence because they are more likely to be mislabeled or confusing, and therefore more valuable for human review.
What is the purpose of outlier sampling in this chapter?Outlier sampling is used to find items that are novel or far from the training data. This helps ensure diversity in the labeled set and can surface unusual examples that confidence-based sampling might miss.
Why does the chapter use a binary task like “disaster-related” vs. “not disaster-related”?A binary task is easier to explain, build, and iterate on in a first human-in-the-loop system. It also makes confidence ranking simpler, since you can focus on items near the 50% decision boundary.
What are the key parts of the simple annotation interface described in the chapter?The chapter emphasizes three practical features: keep the annotator focused on one part of the screen, support hot keys for speed, and provide a back or undo option to correct mistakes. For this binary task, a simple command-line interface is enough for quick annotation.
How does the system improve over time as more annotations are added?After each iteration, newly labeled items are added to the training data and the model is retrained. Over time, the model should improve in F-score and AUC, while the selected items become more diverse and informative as active learning continues.

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