KatInterview

End-to-End Classification: Text Features, Ensembles, and CTR

Machine LearningModel answer
MediumModel answerMachine Learningclassificationfeature-engineeringctr-prediction

Last updated

Walk through a full supervised ML lifecycle covering bag-of-words pipelines, OOB validation, CTR modeling from data to deployment, and debugging a model that degrades in production.

Building and Operating Classification Systems

You're in a technical interview for an ML Engineer role. The interviewer wants to assess how you think end-to-end about supervised classification — from raw features to a live production system.

Address each of the following areas in turn. Be concrete: give technique names, explain why you'd make each choice, and flag trade-offs or common pitfalls.


Part 1 — Text Vectorization

Describe how you'd build a bag-of-words feature pipeline for a text classification task. Your answer should cover:

  • How you tokenize and normalize raw text
  • How you construct and prune a vocabulary without leaking test data
  • What you do with rare terms and words not seen during training
  • How you store the resulting matrix efficiently
  • When you'd use raw counts versus TF-IDF, and what normalization step follows

Part 2 — Out-of-Bag Validation in Ensembles

Explain the out-of-bag (OOB) evaluation technique used in bagging-based methods like random forests:

  • How OOB rows are generated and what fraction you'd expect to be left out per tree
  • How individual OOB predictions are aggregated into a single error estimate
  • Why this is useful and where it can mislead you

Part 3 — Click-Through Rate Prediction

Suppose your team needs a model to predict the probability that a user clicks on an item (ad, recommendation, search result). Walk through the full process:

  • How you define the problem and what makes a well-formed label
  • Where bias enters the training data and how to reduce its impact
  • What features you'd engineer and how you'd handle high-cardinality IDs
  • Which model families you'd try and in what order
  • How you'd verify the model is well-calibrated and evaluate it both offline and online

Part 4 — General Classification Checklist

Separate from the CTR example: if you were handed a new classification problem from scratch, what are the major stages you'd work through? Mention concrete technique choices at each stage.

Part 5 — Debugging a Deployed Model

Three months after launch, online metrics start declining even though offline metrics look fine. How do you investigate? Organize your answer around at least three distinct root-cause categories (data, model, serving, product).

Hints

Hint 1

For Part 1, think carefully about which split you fit the vocabulary on — fitting on all available data is a subtle but serious form of leakage. The hashing trick trades one problem for another; be explicit about the trade-off.

Hint 2

For OOB error, work out the math: what is the probability a single row is excluded from a given bootstrap sample? That number tells you how many trees contribute to each OOB prediction and why the estimate is slightly pessimistic with small ensembles.

Hint 3

For CTR, calibration and offline/online metric gaps are where candidates most often go shallow. Think about why AUC can look great while the model is systematically over- or under-predicting probability, and why offline AUC improvements frequently fail to reproduce in an A/B test.