KatInterview

Preprocessing a Mixed Tabular Dataset Across Model Families

Machine LearningModel answer
MediumModel answerMachine Learningfeature-engineeringscalingmulticollinearity

Last updated

Design leak-safe preprocessing for zero-heavy counts, skewed money, a binary flag and two collinear measurements, and compare choices for linear, tree and k-NN models.

You are building a supervised model on a table with these columns:

  • A – a count variable, mostly small integers, with a large share of zeros. Some values are missing.
  • B – a money amount in dollars with a heavy right tail.
  • C – a binary flag (0/1).
  • D and E – two continuous measurements that are very strongly correlated (|r| > 0.9).
  • y – the target (assume binary classification; say what changes for regression).

Answer the following as you would in a technical screen:

  1. Scaling. State which columns need standardization or normalization, which scaler you would use for each, and why. Say what must be fit on training data only.
  2. The count column A. It has many zeros and missing entries. Describe your options (imputation, zero-inflated or hurdle-style handling, transformations) and how you would validate which one to use.
  3. Correlated D and E. Give three different strategies for selecting or transforming them (for example VIF-based dropping, an L1-type penalty, PCA). Explain how you would choose among them with cross-validation while keeping the model interpretable.
  4. Model families. For regularized linear/logistic models, tree ensembles and k-NN, say exactly how preprocessing should differ and why scale and correlation matter differently for each.
  5. Pipeline and evaluation. Outline a leak-safe, scikit-learn-style pipeline and a cross-validation plan to compare these choices. Include metrics, stratification, and how you would decide statistically whether one pipeline is really better than another.

Hints

Hint 1

Separate the questions 'does the model care about scale?' and 'does the model care about correlation?' for each model family; the answers differ for penalties, splits and distances.

Hint 2

A zero in A and a missing value in A mean different things. Think about encodings that keep both pieces of information (an indicator plus a transformed value) and treat each encoding as something to be compared under identical CV folds.

Hint 3

Anything learned from data (imputer medians, scaler statistics, PCA loadings, VIF-based drops) must be refit inside each fold, so put every step in a single Pipeline and cross-validate that. For comparing pipelines, use repeated stratified folds and look at paired differences rather than single scores.