💸 Earn 20% cashback for every friend you refer who subscribes — Refer & Earn →

What feature engineering questions appear in ML interviews and how do you answer them?

Updated June 18, 2026 · 7 min read · Crack ML Interview

TL;DR

Feature engineering interview questions test the unglamorous skills that decide real model quality: encoding categorical variables, scaling numeric features, handling missing data, preventing leakage, selecting features, and choosing between handcrafted features and learned embeddings. The single highest-signal theme is leakage: fitting any transformation on the full dataset before splitting, or using a feature unavailable at prediction time, is the mistake interviewers probe most. Strong answers tie each technique to when and why you would use it, fit all transformations only on training data, and acknowledge that for tabular data thoughtful feature engineering often beats a fancier model.

Core Transformations and When to Use Them

Encoding categorical variables

Know the main encodings and their tradeoffs. One-hot encoding is safe for low-cardinality categories but explodes dimensionality for high-cardinality features like user or item IDs. Label or ordinal encoding suits genuinely ordered categories but imposes a false ordering on nominal ones. Target encoding, replacing a category with the mean target value, handles high cardinality well but leaks the target and overfits unless you compute it within cross-validation folds or with smoothing. For very high cardinality, learned embeddings are often best. The interview skill is matching the encoding to cardinality and ordinality, and flagging the leakage risk of target encoding.

Scaling, transforms, and missing values

Scaling matters for distance-based and gradient-based models: standardization centers and scales to unit variance, while min-max scaling bounds to a range; tree-based models are scale-invariant and need neither. Skewed features often benefit from a log or power transform. For missing data, distinguish the mechanism and choose accordingly: simple mean or median imputation, model-based imputation, or adding a missingness indicator that lets the model learn that the absence itself is informative. The crucial point to state in every case is that you fit the scaler or imputer on the training data only, then apply it to validation and test, never the reverse.

Leakage and Feature Selection

Preventing feature leakage is the highest-signal answer

Leakage is the dominant feature engineering failure and the topic interviewers probe hardest. It takes two forms. Preprocessing leakage happens when you fit a transformation, scaler, imputer, or target encoder, on the full dataset before the train-test split, contaminating the test set with information from itself. Target leakage happens when a feature encodes information that would not be available at prediction time, such as a field populated only after the outcome occurs. Prevent both by splitting first and fitting only on training data, and by auditing every feature for whether it is truly available at inference time. Proactively naming leakage signals real experience instantly.

Feature selection methods and their tradeoffs

Feature selection improves generalization, reduces cost, and aids interpretability. Filter methods rank features by a statistic like correlation or mutual information independently of the model, which is fast but ignores feature interactions. Wrapper methods like recursive feature elimination search subsets by training the model repeatedly, which is accurate but expensive. Embedded methods like L1 regularization or tree-based feature importance select features as part of training, offering a good balance. Be ready to recommend an approach given constraints: filter for a quick first pass on many features, embedded methods when you are already training a suitable model.

Handcrafted Features vs. Learned Representations

When to engineer features and when to let the model learn them

A frequent conceptual question is whether feature engineering still matters in the deep learning era. The honest answer is that it depends on the data type. For unstructured data like images, text, and audio, deep models learn representations directly and manual feature engineering is largely obsolete. For structured tabular data, which dominates many real business problems, thoughtful feature engineering, including domain-specific interactions, aggregations, and time-based features, frequently outperforms a more complex model on raw inputs. Showing that you choose between handcrafted features and learned embeddings based on data type and problem demonstrates mature judgment.

Feature Engineering Techniques: Use Cases and Pitfalls

TechniqueWhen to UseKey TradeoffPitfall
One-hot encodingLow-cardinality categoriesDimensionality explosion at high cardinalitySparse, wide matrices
Target encodingHigh-cardinality categoriesPowerful but leaks targetOverfitting without fold-wise computation
StandardizationDistance/gradient-based modelsUnnecessary for tree modelsFitting scaler on full data
ImputationMissing valuesSimple vs model-based vs indicatorImputing before the split
L1 feature selectionMany features, sparse solutionMay drop correlated useful featuresAggressive sparsity hurts recall
Learned embeddingsVery high-cardinality or unstructured dataNeeds data and trainingOverkill for small tabular sets

Who this is for

Deep learning enthusiast who undervalues tabular feature work

Profile: Comfortable with neural networks and assumes models can learn everything from raw inputs, with little hands-on tabular feature engineering.

Pain points: Dismisses feature engineering as outdated and gives weak answers on encoding, leakage prevention, and when handcrafted features beat raw inputs on tabular data.

Strategy: Internalize the data-type distinction: deep models learn representations for unstructured data, but engineered features still win on tabular problems. Drill the core transformations and, above all, leakage prevention, since proactively addressing leakage is the highest-signal answer in this topic area.

Practitioner strong on features but loose on leakage discipline

Profile: Builds rich feature sets and knows the encoding and scaling toolkit well, but has occasionally fit transformations before splitting in past work.

Pain points: Describes powerful features fluently but, when probed, does not consistently emphasize fitting transformations on training data only, which interviewers read as a leakage blind spot.

Strategy: Make leakage discipline explicit in every answer: split first, fit preprocessing on the training fold, compute target encoding within cross-validation, and audit each feature for availability at prediction time. Stating these guardrails unprompted converts strong intuition into a clearly trustworthy answer.

FAQ

Q: Is feature engineering still relevant with deep learning?

A: Yes, for structured tabular data, which dominates many real business problems. Deep models learn representations directly for unstructured data like images and text, making manual feature engineering largely obsolete there. But for tabular data, thoughtful encodings, aggregations, and interaction features frequently outperform a more complex model on raw inputs.

Q: How do I prevent data leakage in feature engineering?

A: Split the data first, then fit every transformation, scalers, imputers, and target encoders, on the training fold only and apply it to validation and test. Compute target encoding within cross-validation folds. Audit each feature to confirm it would actually be available at prediction time, since any future-information feature inflates metrics and fails in production.

Q: When should I use target encoding versus one-hot encoding?

A: Use one-hot encoding for low-cardinality categorical features where the resulting dimensionality is manageable. Use target encoding for high-cardinality features where one-hot would be too wide, but compute it within cross-validation folds or with smoothing to avoid leaking the target and overfitting. For extremely high cardinality, learned embeddings are often the better choice.

Want to practice with real, verified ML interview questions from top companies?

Browse the question bank