Feature Engineering Interview Questions and Techniques
The Skill That Actually Wins Interviews
Models are commoditized; features aren't. Interviewers at Airbnb and Stripe increasingly skip "explain XGBoost" and instead hand you a messy column: "This is signup_country with 200 values. What do you do with it?" Feature engineering questions test judgment, and they're frequently asked as live coding — implement the transform from scratch, no sklearn.
Encoding Categoricals: The Core Question
"One-hot or label encoding — when and why?"
- One-hot creates a binary column per category. Safe for linear models because it implies no order, but explodes dimensionality on high-cardinality columns.
- Label encoding maps categories to integers. Compact, fine for tree models (which just split on the integer), but dangerous for linear models — it invents a fake ordering where
France=2is somehow "twice"Spain=1.
That model-dependence is the entire answer interviewers are listening for. Implement both from scratch: One-Hot Encoding and Label Encoding.
def one_hot(values):
categories = sorted(set(values))
return [[1 if v == c else 0 for c in categories] for v in values]
Binning Numeric Features
Binning converts a continuous feature (age, income) into buckets. Why throw away precision? Because it captures non-linear effects in linear models, tames outliers, and sometimes matches the business reality (pricing tiers, age brackets). Know both flavors — equal-width bins versus quantile bins — and that quantile binning handles skewed distributions better. Practice: Binning Numeric Values.
Target Encoding and the Leakage Trap
Target encoding replaces each category with the mean of the target for that category — powerful for high-cardinality features where one-hot is hopeless.
Then comes the follow-up every interviewer asks: "What could go wrong?" Leakage. Each row's encoding includes its own target value, so the feature memorizes the label and validation scores lie. The fixes — out-of-fold encoding, smoothing toward the global mean for rare categories — are exactly what a senior answer includes. Implement it properly: Target Encoding.
Polynomial Features and Interactions
Sometimes the signal is in a combination: price × quantity, or squared distance. Polynomial features generate these systematically, letting linear models fit curves. The trade-off is combinatorial blow-up and overfitting — pair them with regularization. Practice: Polynomial Features.
A Framework for the Open-Ended Question
When handed a raw dataset and asked "what features would you build?", structure your answer:
- Types first — what's categorical, numeric, datetime, text?
- Cardinality check — low-cardinality categoricals get one-hot; high-cardinality get target/frequency encoding.
- Domain interactions — ratios and differences that mean something (revenue per user, days since last order).
- Leakage audit — would this feature exist at prediction time?
That last question separates candidates who've shipped models from those who've only done coursework.
Practice
Our feature engineering problems are all implement-from-scratch coding exercises with test cases — exactly the format used in live screens.
Ready to test your skills?
Practice real Feature Engineering interview questions from top companies — with solutions.
Get interview tips in your inbox
Join data scientists preparing smarter. No spam, unsubscribe anytime.