Data Preparation and Class Imbalance for ML Questions
Preparing training data and handling skewed or shifting distributions. Covers preprocessing and cleaning for model input, data augmentation, distribution shift, class imbalance techniques (resampling, reweighting, threshold tuning), and cold-start scenarios where labeled data is scarce. Focuses on the data-side decisions that determine whether a model can learn at all.
Provide an end-to-end checklist of automated tests you would add to a preprocessing pipeline to prevent regressions: schema checks, distributional tests, null-rate thresholds, and unit tests for individual transformers. For each, state the rationale and a suggested pass/fail policy, and describe how you would run a subset of these as a 'canary' check on incremental data updates to catch newly-introduced leakage before it reaches production.
Compare common outlier-detection techniques for a numeric feature: IQR-based capping or trimming, z-score and robust z-score, Winsorization, and (for a multivariate view) Isolation Forest, Local Outlier Factor, or DBSCAN-based approaches. For each, note the distributional assumptions, sensitivity to sample size and skew, and how treatment differs by downstream model type.
You trained a Random Forest on a dataset with 0.05% positive examples. It reports 99.9% accuracy but zero recall on the positive class. Explain why this happens and propose at least three concrete changes to improve recall while keeping false positives under control.
You need to build a reliable labeled dataset for a rare category you have observed only about 20 times. Propose a strategy that combines bootstrapping from those confirmed examples, weak supervision (heuristic rules), transfer learning from a related task, limited synthetic data generation, and human validation, to produce a training and evaluation set you can trust.
You must pick a decision threshold so that recall stays at or above 0.90 while minimizing false positives (or, symmetrically, maximizing recall subject to a minimum precision constraint). Describe a reproducible approach using cross-validation and a held-out validation set to select the threshold under heavy class imbalance, how you would estimate the expected number of false positives per day at a given daily event volume, and how label lag would affect your recall estimate.
Unlock Full Question Bank
Get access to all Data Preparation and Class Imbalance for ML interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.