Feature Engineering — ML Technical Interview Questions & Answers

Creating informative input variables for a model.

Feature Engineering

  • Simple meaning: A feature is one input column the model sees. Feature engineering is making better columns: hours_per_week instead of raw timestamps, marks_last_test instead of a blob of text, is_weekend as 0/1.
  • Picture: Predicting fail risk. Raw: date of birth. Better: age. Raw: 12 subject marks. Better: average + failed_count. The model is not clever about dates unless you help.
  • How you do it: look at the question, sketch columns a teacher would use, create them in pandas, then train. Domain sense beats random 200 columns.
  • Trap: leaking the target (including “final grade” as a feature when you predict pass/fail). Trap: 100 fancy features on 80 rows — overfit.

Technical Interview Tip: Better columns beat a fancier model. Don’t put the answer in X.

Code Examples for Feature Engineering

Feature Engineering — working example

xs = [10, 20, 30, 40]
mean = sum(xs) / len(xs)
var = sum((x - mean) ** 2 for x in xs) / len(xs)
std = var ** 0.5
z = [(x - mean) / std for x in xs]
lo, hi = min(xs), max(xs)
minmax = [(x - lo) / (hi - lo) for x in xs]
print([round(v, 3) for v in z])
print(minmax)
# sklearn.preprocessing.StandardScaler fits mean/std on train only

Feature Engineering — scaling keeps features comparable — critical for distance-based models and many optimizers.

How to Explain Feature Engineering to an Interviewer

What is a feature?

One input the model uses e.g. hours studied

Give one engineered feature.

age from DOB average of subject marks