Validating a Smile Classifier in a Photo Library App
Machine LearningModel answerLast updated
Design a plan to prove a smile detection feature in a photo app works, covering labels, metrics, hard cases, fairness, pipeline tests, rollout and monitoring.
You work on a photo-management product that includes a feature which decides whether people in a photo are smiling. The result may be used for search ("photos where everyone is smiling"), for suggesting the best shot in a burst, or for automatic album highlights.
Explain how you would check that the feature is correct, from the first offline experiment through to life in production.
Your answer should address:
- What "correct" means for this feature, and what exactly the model outputs (per face, per photo, or a score plus threshold).
- How you would build trustworthy ground truth, including faces where people disagree on whether there is a smile.
- Which metrics and which operating threshold you would use, and why.
- Which difficult cases and population slices you would test explicitly.
- How you would test the surrounding software, not only the model.
- How you would validate the feature during rollout and afterwards.
- How you would respect user privacy while doing all of this.
State any assumptions you make, such as whether a face detector runs upstream and which kind of error hurts the product more.
Hints
Hint 1
Start by pinning down the output and the cost of each error type. Missing a smile and wrongly tagging a smile hurt different features differently, and that drives the threshold.
Hint 2
Ground truth is the hard part: smiles are a spectrum. Think about multiple annotators, written guidelines, an 'unsure' option, and agreement statistics.
Hint 3
Accuracy alone is misleading. Think about precision, recall, a precision-recall curve, calibration, and per-slice results (age, skin tone, lighting, pose, occlusion, image quality).
Hint 4
Verification does not end at launch: consider a shadow mode or staged rollout, implicit user feedback, and drift monitoring on live score distributions.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Define correctness first
Clarify the contract before measuring anything.
- Output: assume the model returns a smile probability per detected face, and a threshold turns it into a label. Photo-level statements ("everyone is smiling") are derived from the face-level results.
- Scope: assume a face detector sits upstream. I would evaluate the smile classifier on its own using ground-truth face boxes, and also end to end, so I can tell which stage causes an error.
- Error costs: for search and highlights, a false positive (a neutral face shown as smiling) is visible and annoying, while a miss just means one fewer result. So I would favor precision at an acceptable recall. For "pick the best shot" suggestions, ranking quality matters more than a hard label.
2. Build ground truth
- Write annotation guidelines: what counts as a smile (mouth corners raised, teeth visible or not, eye crinkling), and how to treat laughing, smirks, and talking.
- Use at least three independent raters per face, plus an "unsure / cannot tell" option.
- Measure inter-rater agreement (Fleiss' kappa or Krippendorff's alpha). Low agreement on a segment signals a vague definition, not a bad model.
- Keep soft labels (fraction of raters who said smile). Evaluate on high-agreement faces for headline numbers, and report separately on contested faces, where the model is judged against the distribution of human opinion.
- Seed the labeling queue with gold items of known answer to catch careless annotators.
- Sample for coverage, not just volume: stratify by lighting, pose, age group, skin tone, accessories, image resolution, and group versus single portraits. Random sampling of a library mostly returns easy frontal faces.
3. Offline metrics
- Report precision, recall, F1 and PR-AUC per class. Accuracy is misleading when the class balance is skewed.
- Choose the threshold on a validation set to hit a target, for example precision at least 95% with the best recall available, then report on a separate untouched test set. Never tune on the test set.
- Check calibration (reliability curve, expected calibration error), since downstream code may use the score for ranking or for combining faces in a group.
- Provide confidence intervals via bootstrap. With a few hundred examples in a slice, a 2-point difference is noise.
- Compare against the current production model and a simple baseline on the same frozen test set.
4. Hard cases and slices
Build targeted test sets for:
- Low light, backlighting, motion blur, heavy compression, low resolution.
- Profile and tilted faces, partial occlusion (sunglasses, masks, hands, food), small faces in group shots.
- Ambiguous expressions: smirk, grimace, laughing, yawning, speaking, closed-eye smiles.
- Babies and older adults, different cultural display norms, facial hair, makeup, filters, and cartoon or printed faces.
For fairness, compute metrics per demographic slice (where legally and ethically obtainable, using consented or annotator-provided attributes) and examine gaps in both false-positive and false-negative rates. Set an explicit tolerance, for example no slice more than a few points below the overall recall at the chosen threshold, and treat violations as launch blockers. Where a slice is too small to measure, collect more data rather than assume parity.
5. Test the software around the model
- Unit tests: preprocessing (crop, resize, color space, EXIF orientation), threshold logic, and aggregation to photo-level.
- Golden-set regression tests: a fixed set of images with expected outputs, run in CI on every model or code change, with tolerance for small score shifts.
- Invariance and perturbation tests: the label should not change under small brightness shifts, horizontal flips, or mild JPEG recompression. Predictions on rotated images should be consistent after orientation handling.
- Consistency of the on-device versus server model if both exist (quantization can shift scores).
- Latency, memory and failure behavior: no face, a huge number of faces, corrupt files.
6. Validate in production
- Shadow mode: run the new model silently beside the old one and compare disagreements. Send a sample of disagreements to human labelers, since those are the most informative items.
- Staged rollout / A/B test: a small percent of users first, with guardrails. Metrics: click-through on smile-filtered search, acceptance of suggested best shots, and user-initiated corrections or dismissals. Treat these as noisy proxies, not ground truth, because behavior is biased by what the product showed.
- Monitoring: track the live distribution of scores and the positive rate over time and by slice, and alert on drift (population stability index or KL divergence against the launch baseline). Periodically relabel a fresh random sample to estimate real precision and recall.
- Feedback loop: provide a low-friction way to report wrong results, and feed these into the hard-case set.
- Rollback plan with clear trigger conditions.
7. Privacy
- Prefer opt-in or consented, donated, or licensed datasets for training and evaluation. Do not have people browse private libraries.
- If production samples are reviewed, require user consent or use on-device evaluation and aggregate-only telemetry (for example federated or differentially private statistics).
- Limit access, de-identify where possible, set retention limits, and log reviewer access.
Common mistakes
- Reporting only accuracy on an easy, imbalanced test set.
- Treating one annotator's label as truth for ambiguous faces.
- Tuning the threshold on the test set, or letting test images leak into training through near-duplicates from the same burst or person.
- Reporting only the overall number and hiding slice gaps.
- Ignoring the upstream face detector, so detection misses are blamed on the smile model (or vice versa).
- Relying on click signals alone as evidence of correctness.
- Launching with no drift monitoring, so a camera or filter trend silently degrades quality.
Summary
Define the output and the costly error, build multi-rater ground truth with measured agreement, choose the threshold from a precision target on held-out data, stress the model with hard and demographic slices, protect the pipeline with regression tests, then confirm with shadow mode, staged rollout and ongoing relabeled samples, all within privacy limits.