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.

HardTechnical
42 practiced

Compare focal loss, class-weighted cross-entropy, and hinge loss for an imbalanced classification problem: how does each change the gradient contribution of easy versus hard examples, what are their key hyperparameters and stability considerations, and in which application would you expect one to outperform the others?

HardTechnical
49 practiced

Design an automated feature selection pipeline that combines stability selection with permutation importance across cross-validation folds. Describe the algorithm, how you'd aggregate scores across folds, how you'd select features robustly from the aggregate, and pitfalls such as correlated features distorting the ranking and selection bias from reusing the same folds for tuning and evaluation.

MediumTechnical
49 practiced

Explain why standard (shuffled) k-fold cross-validation is inappropriate for many time-series tasks, and describe at least two time-aware alternatives: rolling-window (walk-forward) validation and an expanding window. Outline how you would implement one of them in code, and how you would additionally preserve an approximate positive-class ratio per fold if the target is also rare.

MediumTechnical
43 practiced

Describe 'smart' or informed undersampling techniques: Tomek links, Edited Nearest Neighbors (ENN), and NearMiss. Explain how they differ from random undersampling, their typical use cases and effect on class-boundary cleanliness, and how you would validate that an undersampling strategy did not remove important majority-class structure.

MediumTechnical
38 practiced

Write a SQL query that flags outlier transactions per user directly in the warehouse (using the IQR method, or a mean/standard-deviation rule over a trailing window), returning the flagged rows along with the statistics used to flag them. Discuss performance considerations (window functions, indexes/partitions) for a large table and how you would handle users with very little history.

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.