Target Encoding Restaurant IDs Without Leaking the Label
Last updated: November 29, 2026
Quick Overview
Your Uber Eats conversion model needs a feature for restaurant identity with 800k distinct restaurants. Explain how to target encode it safely and implement out-of-fold encoding.
Uber
November 29, 20260
0
0 solved
Your Uber Eats conversion model needs a feature for restaurant identity with 800k distinct restaurants. Explain how to target encode it safely and implement out-of-fold encoding.
High-cardinality IDs (restaurants, eaters, drivers) are everywhere in Uber models and naive target encoding is a common source of offline gains that vanish in production. The interviewer checks that you know the leakage mechanism and a concrete fix.
What the Interviewer Expects
- Explain why plain mean target encoding leaks
- Use out-of-fold encoding on training data
- Apply smoothing toward a global prior for rare categories
- Compute serving-time encodings from training data only
- Mention alternatives like hashing or learned embeddings
Key Topics to Cover
How to Approach This
- Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
- Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
- Feature engineering is often more impactful than model selection.
- Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
- Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
- How do you choose the smoothing strength?
- How would you handle a restaurant that opened yesterday?
- Would you still target encode when training a deep model?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Explore ML Interview PrepSample Answer
Clarify
Each row is an impression of a restaurant to an eater, label 1 if it led to an order. Restaurants follow a long tail: a few thousand have millions of impressions, most have a handful....
Approach
Plain encoding replaces the ID with the restaurant's mean label computed over all training rows. For a restaurant with 2 impressions, that mean includes the row's own label, so the feature is nearly t...