Design a validation scheme for multi-year patient records with an imbalanced label

Quick Overview

Asks how to design cross-validation for a dataset with many records per patient over several years and a rare positive label. Tests reasoning about leakage between related records, time-aware splits, class imbalance and how to report reliable model performance.

Design a validation scheme for multi-year patient records with an imbalanced label

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: hard

Interview Round: Other

Your dataset has multiple records per patient collected over several years and an imbalanced label. How would you design the validation scheme? ```hint Find the leaks List every way information about a validation record could already be present in the training data. Think about who each record belongs to and when it was collected. ``` ```hint Match production Ask who the model will score after deployment: new patients, returning patients, or future visits of known patients. The split should reproduce that situation. ``` ```hint Rare positives With few positive cases, think about what can go wrong inside a single fold and which metrics still say something useful. ``` ### Clarifying Questions to Ask - Will the deployed model score patients it has never seen, future visits of patients already in the data, or both? - Is the label defined per record or per patient, and can one patient have both positive and negative records? - How many positive patients are there in total, not just positive records? - Is each prediction made at a specific point in time, and which data is available at that moment? - Did coding practices, treatments or data collection change over the years covered? ### What a Strong Answer Covers - Grouping by patient so no patient's records sit on both sides of a split, and why mixing them inflates scores. - Handling the imbalance in fold construction, metric choice and resampling. - Handling time with forward-chaining splits and point-in-time features that match how the model is deployed. - A complete protocol with an untouched test set, a model selection procedure and honest uncertainty reporting. ### Follow-up Questions - The label is per record and a patient can have both positive and negative records. How do you stratify, and what exactly does the model predict? - How would you detect that a feature leaks information from after the prediction date? - Most positives fall in the last two years because of a change in diagnostic coding. How does that change your split and your metrics? - How would you put a confidence interval on PR-AUC when many records come from the same patient?

Overview: Asks how to design cross-validation for a dataset with many records per patient over several years and a rare positive label. Tests reasoning about leakage between related records, time-aware splits, class imbalance and how to report reliable model performance.

Nov 24, 2026
hardMachine Learning EngineerOtherMachine Learning
0
0

Your dataset has multiple records per patient collected over several years and an imbalanced label. How would you design the validation scheme?

Clarifying Questions to Ask Guidance

  • Will the deployed model score patients it has never seen, future visits of patients already in the data, or both?
  • Is the label defined per record or per patient, and can one patient have both positive and negative records?
  • How many positive patients are there in total, not just positive records?
  • Is each prediction made at a specific point in time, and which data is available at that moment?
  • Did coding practices, treatments or data collection change over the years covered?

What a Strong Answer Covers Guidance

  • Grouping by patient so no patient's records sit on both sides of a split, and why mixing them inflates scores.
  • Handling the imbalance in fold construction, metric choice and resampling.
  • Handling time with forward-chaining splits and point-in-time features that match how the model is deployed.
  • A complete protocol with an untouched test set, a model selection procedure and honest uncertainty reporting.

Follow-up Questions Guidance

  • The label is per record and a patient can have both positive and negative records. How do you stratify, and what exactly does the model predict?
  • How would you detect that a feature leaks information from after the prediction date?
  • Most positives fall in the last two years because of a change in diagnostic coding. How does that change your split and your metrics?
  • How would you put a confidence interval on PR-AUC when many records come from the same patient?