Feature engineering and data preparation
- ML fundamentals
- Asked in most interview loops
- About 2 h 30 min to learn
- 3 vetted resources
What this topic covers
Turning raw columns into inputs a model can learn from, without letting information from the test set or the future leak in. That means handling missing values (drop, impute or flag), encoding categoricals (one-hot, hashing or target encoding), scaling numeric features for the models that care about scale, and dealing with class imbalance. It also means splitting data the way the model will be used: by time when it predicts the future, and by user or group when the same entity appears in many rows. Interviewers check that you fit every preprocessing step on the training data only, spot leakage in a described pipeline, choose an encoding for a high-cardinality feature, and know which models need scaled inputs.
You’re ready when you can
What interviewers check, from the resources below.
- Choose between linear scaling, Z-score scaling, log scaling and clipping for a given feature distribution
- Explain one-hot encoding, how to handle out-of-vocabulary values and what to do when the vocabulary is huge
- Describe downsampling and upweighting for an imbalanced dataset, and why the upweighting is needed
- List what makes a test set trustworthy, including no duplicates of training examples
- Explain why scaling or feature selection fitted on the full dataset before splitting inflates validation scores
- Show how a Pipeline keeps preprocessing inside each cross-validation fold
- Explain why test data must never be passed to fit or fit_transform
- Explain what goes wrong when training and test data go through different transformations
- Choose a split for time-ordered data and for data with many rows per customer
- Explain which steps must happen inside resampling to avoid information leakage
Feature engineering and data preparation interview questions
Answer out loud, then open the points a strong answer covers. All Machine learning interview questions
How would you encode a categorical feature with thousands of distinct values?
- One-hot encoding creates a sparse column per category, which suits linear models with a modest vocabulary but grows huge here and leaves rare categories with too few examples to learn from.
- Group rare categories into an “other” bucket, hash values into a fixed number of buckets and accept some collisions, or learn an embedding when a neural network consumes the feature.
- Target encoding replaces each category with a smoothed mean of the label, but it must be fitted out of fold or on separate data, or it leaks the label and overfits.
Only 1% of your training examples are positive; what would you change in how you train the model?
- First check whether the minority class has enough examples to learn from at all; if it does, a standard model with a tuned decision threshold is often enough.
- Downsample the majority class so each batch contains positives, then upweight the kept majority examples by the same factor so predicted probabilities still reflect the real base rate.
- Resample only the training set, keep the true class ratio in validation and test, and compare approaches with precision–recall metrics at the threshold the product will actually use.
What to study, in order
Each link opened and checked by hand; the date says when.
Start here
Working with numerical data (opens in a new tab)
Google Machine Learning Crash Course · Google for Developers · 80 min · Free · checked 26 Oct 2026
- Why
- Interviewers ask how you would prepare messy columns before training, and expect concrete choices for scaling, bucketing, missing values, categoricals and imbalance.
- What to read
- Read “Normalization”, “Binning”, “Scrubbing” and “Qualities of good numerical features”; continue into the Working with categorical data module for “Vocabulary and one-hot encoding” and the “High dimensionality” part of “Common issues”; then, in the Datasets, generalization, and overfitting module, read “Imbalanced datasets” and “Dividing the original dataset”.
- What to skip
- The programming exercises, “Polynomial transforms”, “Feature crosses” and its exercises, and the label-quality parts of “Common issues”.
Free alternative
12. Common pitfalls and recommended practices (opens in a new tab)
scikit-learn User Guide · scikit-learn developers · 20 min · Free · checked 26 Oct 2026
- Why
- Leakage is the classic way a model looks great offline and fails in production, and interviewers expect you to spot it in a described pipeline.
- What to read
- Read “12.1. Inconsistent preprocessing” and all of “12.2. Data leakage”, including “12.2.1. How to avoid data leakage” and “12.2.2. Data leakage during pre-processing”.
- What to skip
- “12.3. Controlling randomness”, unless you are asked about reproducible splits.
Go deeper
Feature Engineering and Selection: A Practical Approach for Predictive Models (opens in a new tab)
feat.engineering · Max Kuhn and Kjell Johnson · 100 min · Free · checked 26 Oct 2026
- Why
- It treats splitting, encoding and missing data as modelling decisions with trade-offs, the depth a senior interviewer probes after the textbook answer.
- What to read
- In chapter 3 read “3.3 Data Splitting”, “3.4.1 V-Fold Cross-Validation and Its Variants”, “3.4.4 Rolling Origin Forecasting” and “3.4.7 What Should be Included Inside of Resampling?”; in chapter 5 read “5.1 Creating Dummy Variables for Unordered Categories” to “5.4 Supervised Encoding Methods”; in chapter 8 read “8.1 Understanding the Nature and Severity of Missing Information” to “8.5 Imputation Methods”.
- What to skip
- The R “Computing” sections, the long case-study figures, chapter 5’s ordered and text encodings, and chapters 9–12 on profile data and feature selection.
Companies that test ML fundamentals most
Put Feature engineering and data preparation in your plan
Tell us your interview date and hours a day; it lands on the right day, in the right order.