Sunday, September 13, 2026
HomeData ScienceFeature Engineering Interview Questions – Top 30 with Answers 2026

Feature Engineering Interview Questions – Top 30 with Answers 2026

Table of Content

Feature engineering is consistently cited by Kaggle grandmasters and senior ML practitioners as the highest-leverage skill in applied machine learning — more impactful than model selection or hyperparameter tuning. Yet it is often underemphasised in coursework and interviews. This guide covers the 30 most important feature engineering interview questions with detailed answers, covering categorical encoding, numeric transformations, feature selection, and advanced techniques.

Categorical Feature Encoding

Q1. What is the difference between one-hot encoding and label encoding? When do you use each?
Label encoding assigns each category an integer: [“cat”, “dog”, “bird”] → [0, 1, 2]. This implies an ordinal relationship — “dog” is numerically between “cat” and “bird.” For tree-based models (decision trees, random forests, XGBoost), this is fine because splits are based on thresholds, not mathematical relationships. For linear models and neural networks, label encoding of nominal (unordered) categories introduces false ordinal structure that misleads the model. One-hot encoding (OHE) creates a binary column for each category: {“cat”: [1,0,0], “dog”: [0,1,0], “bird”: [0,0,1]}. No false ordering. Problem: high-cardinality features (1000+ categories) produce huge, sparse matrices. Use label encoding for tree models with nominal features. Use OHE for linear/neural models with low-cardinality features (< 15-20 categories). Use embeddings for neural models with high-cardinality features.

Q2. What is target encoding and what is its main risk?
Target encoding (mean encoding) replaces each category value with the mean of the target variable for that category. For a churn prediction task, “city=Mumbai” would be encoded as the average churn rate of Mumbai customers. This is powerful — it creates a numeric feature that directly captures the relationship between the category and the target. The main risk is data leakage: if you compute the mean churn rate for “Mumbai” using the same rows you then train on, the model memorises the target rather than learning a generalising pattern. The fix is k-fold target encoding: for each row, compute the category mean using all other folds, never using the row’s own target value. Add Laplace smoothing for rare categories (blend the category mean toward the global mean). Catboost implements ordered target statistics internally, making it safe from this leakage.

Q3. What is frequency encoding?
Frequency encoding replaces each category value with how often it appears in the dataset. A city that appears 5000 times gets encoded as 5000 (or normalised as 5000/total_rows). It preserves cardinality information without the data leakage risk of target encoding. Useful when frequency genuinely correlates with the target (popular products are often better-selling; rare cities may be anomalies). Also useful as a simple technique for high-cardinality features when target encoding’s complexity is not warranted. Implement in pandas: df[‘city_freq’] = df[‘city’].map(df[‘city’].value_counts()).

Q4. How do you handle a feature with 10,000 unique categories?
High-cardinality categorical features need special handling. Options by complexity: (1) Frequency encoding — quick, no leakage risk. (2) Target encoding with k-fold cross-validation — more powerful. (3) Hashing trick (feature hashing) — hash the category to a fixed-size vector of m bins, reducing 10,000 categories to m (e.g., 256) dimensions. Collisions are acceptable; m should be a power of 2. (4) Entity embeddings — train a neural network to learn a dense embedding for each category, capturing semantic similarity. (5) Grouping rare categories — combine all categories with frequency below a threshold into an “Other” bucket. (6) Domain-driven grouping — group city into region using business logic. The best approach depends on whether the cardinality is meaningful (product IDs vs. city names) and the model type.

Q5. What is binary encoding?
Binary encoding first applies label encoding (integer), then converts the integer to binary, and uses each binary bit as a separate feature. A feature with 1000 categories needs 1000 OHE columns but only 10 binary columns (2^10 = 1024). It is a middle ground between OHE (no false ordering, many columns) and label encoding (false ordering, one column). Useful for high-cardinality nominal features when OHE is too wide. Available in the category_encoders Python library.

Numeric Feature Transformations

assorted numbers photography
Photo by Nick Hillier on Unsplash

Q6. When do you apply log transformation and why?
Apply a log transform when a numeric feature is right-skewed — most values are small with a long tail of large values. Income, transaction amounts, prices, city populations, and website traffic typically follow power-law or log-normal distributions. Problems with skewed features: linear models assume normally distributed errors; extreme values dominate L2-based metrics; gradient descent converges slowly. Log(x) or Log(x+1) (if x can be 0) compresses the right tail, making the distribution more symmetric and closer to normal. After log transformation, a ratio of raw values becomes a difference in log values: log(a/b) = log(a) – log(b). Box-Cox transformation generalises log transform, choosing the optimal power parameter λ that maximises normality: if λ=0, it is log; if λ=0.5, it is square root. Yeo-Johnson extends Box-Cox to handle zero and negative values.

Q7. What is the difference between normalisation (Min-Max scaling) and standardisation (Z-score scaling)?
Min-Max normalisation scales to [0, 1]: x_scaled = (x – x_min) / (x_max – x_min). Bounded output, but extreme outliers compress the rest of the distribution — one outlier at x=10,000 compresses everything else into [0, 0.01]. Sensitive to outliers. Use for: neural networks with sigmoid/tanh activations (need bounded input), image pixel values. Z-score standardisation: x_scaled = (x – mean) / std. Zero mean, unit variance. Not bounded — outliers shrink but do not disappear. Less sensitive to outliers. Use for: linear models, SVM (RBF kernel is based on Euclidean distance), PCA (requires zero-mean). Neither normalisation nor standardisation is needed for tree-based models (XGBoost, Random Forest) — splits are threshold-based and invariant to monotonic transformations.

Q8. What are interaction features and when do you create them?
Interaction features capture the combined effect of two or more features that a linear model cannot learn individually. For a linear model, the effect of age and income on loan default is modelled as w₁×age + w₂×income. But maybe only young people with low income default at high rates — the interaction matters. Creating age × income as a new feature allows the linear model to capture this. Common interactions: product of two numeric features, ratio (price_per_sqft = price / area), difference (age_of_account – days_since_last_login), and binary flag combinations. Tree-based models learn interactions automatically — they are most needed for linear models and logistic regression. Polynomial features (sklearn PolynomialFeatures) systematically create all pairwise (and higher-order) interactions up to degree d.

Q9. What are date/time features and how do you extract them?
Raw timestamps are meaningless to most models — a Unix timestamp of 1725350400 tells a model nothing. Extract: year, month, day, hour, minute, day_of_week (0-6), day_of_year (1-365), week_of_year, quarter, is_weekend (bool), is_holiday (bool), days_since_epoch, time_since_last_event, hour_of_day as cyclical features. Cyclical encoding: hour 23 and hour 0 are adjacent, but 23 – 0 = 23 ≠ 1. Use sin/cos encoding: hour_sin = sin(2π × hour / 24), hour_cos = cos(2π × hour / 24). This preserves cyclical proximity. Similarly encode day_of_week (period=7) and month (period=12). Domain-specific: days_since_customer_created, days_until_subscription_renewal, days_since_last_purchase — these temporal proximity features are often the most predictive.

Q10. What is the difference between feature selection and feature extraction?
Feature selection chooses a subset of the original features to keep — the features themselves are unchanged. Methods: filter (correlation, mutual information, chi-square — computed independently of the model), wrapper (RFE, forward selection — use the model to evaluate subsets), and embedded (LASSO L1 regularisation, tree-based feature importance — feature selection happens during model training). Feature extraction creates new features from the original features — often in a lower-dimensional space. Methods: PCA (linear combination of original features), autoencoders (non-linear compression), t-SNE/UMAP (non-linear, primarily for visualisation), NMF. Feature selection preserves interpretability (you keep original features). Feature extraction typically loses interpretability but can capture more complex structure.

Advanced Feature Engineering Techniques

Q11. What are lag features and rolling window features in time series?
Lag features capture the value of a variable at a previous time step: sales_lag_1 = yesterday’s sales, sales_lag_7 = sales one week ago. They allow the model to learn autocorrelation — today’s sales correlate with yesterday’s. Rolling window features compute statistics over a sliding window of past observations: sales_rolling_7d_mean, sales_rolling_30d_std, sales_rolling_7d_max. These capture trends and volatility in the recent past. Both types must be created carefully to avoid leakage: for a model predicting day t’s sales, lag_1 is day t-1 (OK), but you cannot use day t’s value itself or any feature derived from it.

Q12. What is the Featuretools library and automated feature engineering?
Featuretools automatically generates features from relational data using deep feature synthesis (DFS). Given a set of related tables (customers, orders, products), it creates features across table relationships: “mean order value per customer”, “number of orders in the last 30 days”, “max product price per order”. It systematically applies aggregation and transformation primitives to generate hundreds or thousands of candidate features. You then apply feature selection to keep the most predictive ones. Useful for jump-starting feature engineering on complex relational datasets. AutoML systems like AutoGluon and H2O also perform automated feature engineering internally.

Q13–20 (Feature engineering rapid fire):

Q13. What is WOE (Weight of Evidence) encoding? Used for binary classification with credit/risk models. WOE = ln(Distribution of Events / Distribution of Non-Events) for each category bin. Captures the relationship between categories and the binary target, handles missing values naturally, and ensures monotonic relationship with the target. Information Value (IV) measures total predictive power of a feature.

Q14. What is feature hashing (hashing trick)? Maps high-cardinality categorical values to a fixed-size vector using a hash function. Avoids storing a vocabulary mapping, handles new unseen categories gracefully, and is memory-efficient. Collision risk (different categories hash to same index) is usually tolerable. Used in linear models for web-scale data.

Q15. How do you create features for text data without deep learning? TF-IDF vectors (bag-of-words, weighted), character n-gram frequencies, text statistics (word count, sentence count, avg word length, punctuation count, ratio of uppercase), readability scores (Flesch-Kincaid), sentiment scores (VADER), and named entity counts.

Q16. What is the curse of dimensionality and how does it affect feature engineering? Too many features relative to training examples causes overfitting — the model learns noise. Rule of thumb: need ~10-20 examples per feature for stable estimates. Always apply feature selection after creating many features. Use L1 regularisation (automatically zeros unimportant features) or tree-based feature importance + top-k selection.

Q17. What is a feature store? A centralised repository for storing, serving, and reusing computed features across different models and teams. Addresses training-serving skew by ensuring the same feature computation logic is used in both. Examples: Feast (open source), Tecton, AWS SageMaker Feature Store, Databricks Feature Store.

Q18. When should you clip or winsorise a feature? When extreme outliers exist that are genuine (not data errors) but distort model training. Winsorising caps values at specified percentiles (e.g., 1st and 99th). Clipping at domain boundaries (age cannot exceed 120, count cannot be negative). Different from removing outliers — the values are kept but truncated.

Q19. What is embedding as a feature engineering technique? Dense vector representations of categorical or structured data learned by neural networks. Word embeddings for text tokens, entity embeddings for high-cardinality categoricals (trained jointly with the main model), graph embeddings (Node2Vec) for network features. Captures semantic similarity that OHE cannot.

Q20. How do you handle a target-correlated feature that should not be used? Remove it before training. Features like “days_in_hospital” for predicting “did patient recover” may be a consequence of recovery, not a cause — using it is target leakage. Always ask: “Would this feature value be known at prediction time, before the target event occurs?” If no, remove it.

Code: Feature Engineering Pipeline

a computer screen with a bunch of code on it
Photo by Chris Ried on Unsplash
import pandas as pd
import numpy as np
from sklearn.pipeline import Pipeline
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from category_encoders import TargetEncoder
from sklearn.model_selection import cross_val_score, KFold

# Define column types
num_cols  = ['age', 'income', 'tenure_days']
cat_low   = ['gender', 'plan_type']          # low cardinality → OHE
cat_high  = ['city', 'product_category']     # high cardinality → target encode

# Numeric features: log skewed, then standardise
def make_numeric_pipeline():
    return Pipeline([('scaler', StandardScaler())])

# Target encoding with k-fold to prevent leakage
def make_high_card_pipeline():
    return Pipeline([('te', TargetEncoder(cols=cat_high, smoothing=10))])

preprocessor = ColumnTransformer([
    ('num',      make_numeric_pipeline(),  num_cols),
    ('cat_ohe',  OneHotEncoder(handle_unknown='ignore', sparse=False), cat_low),
    ('cat_high', make_high_card_pipeline(), cat_high),
])

# Interaction features
df['income_per_tenure'] = df['income'] / (df['tenure_days'] + 1)
df['age_income']        = df['age'] * np.log1p(df['income'])

# Cyclical time features
df['hour_sin'] = np.sin(2 * np.pi * df['hour'] / 24)
df['hour_cos'] = np.cos(2 * np.pi * df['hour'] / 24)
df['dow_sin']  = np.sin(2 * np.pi * df['day_of_week'] / 7)
df['dow_cos']  = np.cos(2 * np.pi * df['day_of_week'] / 7)

Conclusion

Feature engineering is where domain expertise meets statistical intuition. The best features come from asking “what information would a human expert use to make this prediction?” — then finding a way to encode that information numerically. Study the data distribution of every feature before modelling; understand why each feature might be predictive; and always validate that features do not introduce leakage. In Kaggle competitions and real-world deployments alike, teams with superior feature engineering consistently outperform those who rely on more complex models alone.

Leave feedback about this

  • Rating

Durgesh Kekare
Durgesh Kekarehttps://www.dataexpertise.in
Durgesh Kekare is a data science educator and founder of DataExpertise.in. With expertise in Python, machine learning, and analytics, he helps 10,000+ learners break into data careers.

Latest Posts

List of Categories