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.

MediumTechnical
46 practiced

Enumerate the common sources of data leakage introduced during preprocessing: temporal leakage (using information not yet available at prediction time), aggregate features computed using future or target-derived information, and scaling or encoding fit on the full dataset before splitting. For each source, give a concrete example, how you would detect it, and how you would prevent it in a pipeline (including an automated test you could add to CI).

EasyTechnical
49 practiced

In scikit-learn, what is the difference between calling fit_transform on your training features and calling transform (not fit_transform) on your test features? Show the code, and explain concretely what information would leak into your evaluation if you fit the scaler on the combined train+test data instead.

MediumTechnical
77 practiced

A stakeholder tells you to 'catch every case' of a rare, costly outcome (fraud, churn, a safety incident) regardless of false positives. How do you explain the precision/recall trade-off to a non-technical audience, translate it into business terms (operational cost, reviewer time), and propose a plan that balances detection with the team's capacity to act on alerts?

MediumTechnical
50 practiced

Design a checklist and technical approach to make a preprocessing pipeline reproducible across a team: versioning of code and dependencies, deterministic transforms (fixed random seeds), serialization of fitted transformers and scalers, data contracts and schema checks, and unit or integration tests. How would you enforce this via CI/CD, and how would you document it so both engineers and non-technical stakeholders can trust and audit a given model run?

EasyTechnical
53 practiced

Implement a function that flags outlier rows in a numeric column using the IQR method (below Q1 minus k times IQR, or above Q3 plus k times IQR), handling NaNs gracefully. Give a short example and note the method's limitations on a skewed distribution.

Unlock Full Question Bank

Get access to all Data Preparation and Class Imbalance for ML interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.