Let’s Get Certified
Module 04 / 13 · Data preparation for ML and AI

Keep quality, bias and prevalence visible in validation

A parcel classifier works in daylight and fails on low-light images.

Keep quality, bias and prevalence visible in validation

A parcel classifier works in daylight and fails on low-light images. Its aggregate score hides the issue because most deliveries happen by day. Separate label reliability, representation and the cost of each decision error.

At 41:17 the speaker separates rare-class training treatment from the evaluation distribution. The worked case keeps the production prevalence visible.

Work through the decision

A validation set has 10,000 payments and 20 confirmed frauds. A model flags none. What do its accuracy and recall tell you?

Check your reasoning

Accuracy is 99.8%, yet recall for confirmed fraud is zero. Keep a representative held-out set and compare precision and recall at a threshold that fits the review team’s capacity.

MLA-C02 recording · 41:17

Continue in the recording · 32:11 · 38:59.

Decisions and tradeoffs

Independent annotation review
Compare independent labels or adjudicate conflicts against a rubric to distinguish label noise from model error.
Representative held-out slices
Preserve production-like prevalence in evaluation and report metrics by meaningful operating condition.
Training-only resampling
Apply resampling exclusively to the training split after partitioning by entity or time as appropriate.
Precision and recall
Precision measures the fraction of positive predictions that are correct; recall measures the fraction of actual positives found.
Schema and range validation
Enforce types, permissible ranges and required fields at ingestion, retaining failures for review.
Provenance and content hashes
Record trusted versions and verify integrity before training so unexpected changes can be traced.
Slice-aware collection
Collect sufficiently varied examples for the underrepresented operating condition and verify performance on an independent slice.
Train-fitted imputation
Fit fill values on training data and preserve indicators when missingness itself may carry information.

Set a threshold with the review team

At threshold A, 12 of 20 actual frauds are flagged, with 8 false alarms. Lowering the threshold to B catches 16 but adds enough false alarms that 40 payments are now flagged.

Threshold   Recall   Precision   Reviews
A           12/20    12/20       20
B           16/20    16/40       40

Threshold B raises recall from 60% to 80% and reduces precision from 60% to 40%. A daily capacity of 25 reviews changes which threshold is usable. Estimate both at production prevalence.

Practice each guide skill

The numbers below follow the AWS task and skill identifiers.

  1. Validate a new batch for missing keys, type changes, unrealistic ranges and duplicate IDs before admitting it to training.
  2. Label a sample twice under a shared rubric and adjudicate disagreements. Version the corrected set.
  3. Measure representation and errors by relevant groups, investigate sourcing or annotation bias and evaluate mitigations with SageMaker Clarify where applicable.
  4. Compare the mix of languages, lighting conditions and numeric ranges. Measure each underrepresented slice separately.
  5. Apply training-only weighting or resampling and preserve natural prevalence in validation. Report precision and recall at a useful threshold.
  6. Verify checksums, approved source versions and labeling lineage. Hold an unexplained revision for review.
  7. Treat corrupt records, missing optional values and repeated observations differently. Fit imputations without observing validation statistics.

Official objectives for this lesson

Related lesson · Keep bad records from quietly reaching consumers

Knowledge check

Keep quality, bias and prevalence visible in validation quiz

Answer 3 questions. Check each answer for an explanation.