LearnThatStack Ace your next interview
Machine Learning & Data Science
Data Preparation & Feature Engineering.
Change topic Change
Practice · Questions

All questions

Showing of 58
Beginner 18
01

What is data leakage, and why does it wreck an otherwise good model?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Leakage means your training data contains information that would not exist at prediction time, or that quietly encodes the answer. The model learns that shortcut, because it is the easiest signal available.

The damage is that your offline numbers become fiction. Validation accuracy looks excellent, so you stop investigating and ship. In production the leaked column is empty, or it arrives after the decision, and performance collapses toward baseline.

It is hard to catch because nothing crashes. The code is correct; the data is wrong. A classic case is predicting fraud using a chargeback_filed column, when chargebacks only get filed after fraud is confirmed.

The cost is time and trust. Weeks of tuning on a leaked feature buy nothing, and business decisions get made on a number that was never true.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

What is feature engineering, and how much does it change model performance?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Feature engineering is the work of reshaping raw columns into inputs that expose structure the model can actually use. A raw timestamp is nearly useless; hour of day, day of week, and days since last order are not.

On tabular data the effect is large, usually larger than swapping model families. A gradient-boosted tree with well-built ratios and aggregates beats a heavily tuned network fed raw columns. Most real gains on structured problems come from the features.

The exception is domains where the model learns its own representation. For images, audio, and text, deep networks build features internally, so hand-crafted ones add little.

The cost is time and maintenance. Every engineered feature is code that must run identically in training and in serving, or the model sees something different once it is live.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

Why does domain knowledge matter so much when you engineer features?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Domain knowledge tells you which combinations of columns mean something, and a blind search over raw columns cannot guess that. In card payments, transaction amount alone is weak. Amount divided by that customer's usual amount is strong.

It also tells you what exists at decision time. Someone who runs the process knows the risk score is written back two days later. That single fact prevents a leaked feature from ever being built.

It flags proxies too. Postcode often stands in for income or ethnicity, which matters for fairness and for stability when a neighborhood changes.

Without it, you brute-force thousands of combinations and hope a selection method sorts them out. That is slower, noisier, and produces features nobody can explain to the team relying on the prediction.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

How do you handle categorical variables so a model can use them?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Models need numbers, so every category has to become one without inventing an order that is not there. Two questions decide the method: do the categories have a real ordering, and how many distinct values exist?

Few values and no order means one indicator column per value. Few values with a genuine order means integer codes that preserve it. Many values means grouping the long tail into "other", hashing, target statistics, or a learned embedding.

The model family matters as well. Trees split on integer codes without reading them as magnitudes, so they tolerate compact encodings. Linear and distance-based models read 3 as three times 1.

Whatever you pick, store the mapping as a fitted object rather than ad-hoc code. Serving must produce the same columns in the same order, or the model silently scores garbage.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

What is one-hot encoding, and how does it change your dataset's dimensionality?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

One-hot encoding replaces a categorical column with one binary column per distinct value; each row carries a single 1. A color column of red, green, and blue becomes three columns.

df["color"].nunique()                        # 3
pd.get_dummies(df, columns=["color"]).shape  # (1000, 12), was (1000, 10)

Dimensionality grows with cardinality, not with row count. One column of k values costs k columns. Three columns of 100 values each add 300, and the resulting matrix is over 99 percent zeros.

That width costs memory and fit time, and it hurts trees in particular. A tree splits one column at a time, so a category spread across 100 binary columns needs depth to isolate. Sparse storage fixes the memory, not the depth. Past a few dozen values, reach for another encoding.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

06

When would you use ordinal encoding instead of one-hot encoding?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Reach for ordinal encoding when the categories have a genuine order and the model can exploit it. Low, medium, and high severity, education level, t-shirt sizes, and survey ratings all carry order that one-hot throws away.

Encoded as 1, 2, 3, the model can learn a single split at "greater than 2". One-hot would need several splits to express the same idea, and it treats each level as unrelated.

The second case is high cardinality feeding a tree model. Integer codes keep the frame narrow, and trees do not read the integers as magnitudes anyway.

The cost lands on linear and distance-based models. They assume the gap from 1 to 2 equals the gap from 2 to 3. If your order is invented, say country codes, you have handed the model a relationship that does not exist.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

07

What is feature scaling, and when is it essential?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Scaling puts numeric features onto comparable ranges so no feature dominates purely because of its units. Salary in the tens of thousands and age in the tens are not comparable until you fix that.

It is essential wherever the algorithm compares magnitudes across features. Distance-based methods like k-nearest neighbors and k-means, support vector machines, principal component analysis, and any model with a regularization penalty all qualify. Neural networks need it too.

The mechanism repeats each time. Distance sums squared differences, so the widest feature owns the result. A penalty applied per coefficient shrinks whichever features happen to use small units. Variance-maximizing methods follow units directly.

Tree-based models do not need it. The failure mode elsewhere is quiet: nothing errors, the model just ignores your small-scale features. Fit the scaler on training rows only.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

08

What is the difference between normalization and standardization?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Normalization usually means min-max scaling: subtract the minimum, divide by the range, landing every value between 0 and 1. Standardization subtracts the mean and divides by the standard deviation, giving mean 0 and spread 1 with no fixed bounds.

The practical split is bounds versus distribution. Min-max guarantees a range, which suits pixel values and network inputs that expect one. Standardization guarantees location and spread, which is what linear models and principal component analysis assume.

Neither changes the shape of the distribution. Standardizing a skewed column leaves it skewed; if you wanted symmetry, you need a log or power transform instead.

Min-max is the fragile one. A single extreme maximum squeezes every other value into a narrow band near zero, and the range you fitted on rarely holds for future data.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

09

How do you handle missing values in a dataset?

Part of Pro
10

What are the common ways to impute missing data, and when does each fit?

Part of Pro
11

What is an outlier, and how does it distort your analysis and models?

Part of Pro
12

How do you detect outliers in a dataset?

Part of Pro
13

What is vectorization, and why is it preferred over looping in pandas?

Part of Pro
14

What is the difference between loc and iloc, and when do at and iat help?

Part of Pro
15

What are the three stages of a pandas groupby: split, apply, and combine?

Part of Pro
16

What is the difference between merge, join, and concat in pandas?

Part of Pro
17

What does an inner join do, and how do left, right, and outer differ?

Part of Pro
18

How do you merge two DataFrames on multiple columns or on the index?

Part of Pro
Intermediate 33
19

How do you prevent data leakage during preprocessing?

Part of Pro
20

What are the main types of data leakage, and what does each look like?

Part of Pro
21

Your model scores suspiciously well - how do you hunt for leakage?

Part of Pro
22

How can feature engineering itself introduce data leakage?

Part of Pro
23

How does a scikit-learn pipeline prevent leakage, and what does it not cover?

Part of Pro
24

What is the difference between data leakage and overfitting?

Part of Pro
25

How does target encoding leak the target, and what is the fix?

Part of Pro
26

What is the dummy variable trap, and how do you avoid it?

Part of Pro
27

Your city column has 50,000 unique values - how would you encode it?

Part of Pro
28

A category appears at inference that training never saw - what do you do?

Part of Pro
29

How do you choose a scaling method for a given model and dataset?

Part of Pro
30

How does feature scaling affect gradient descent convergence?

Part of Pro
31

Do random forests and gradient-boosted trees need feature scaling?

Part of Pro
32

Your data has heavy outliers - how does that change your scaling choice?

Part of Pro
33

With outliers present, should you impute with the mean or the median?

Part of Pro
34

What do MCAR, MAR, and MNAR mean, and why does the difference matter?

Part of Pro
35

How do KNN and iterative imputers differ from simple mean imputation?

Part of Pro
36

A column is over 30% missing - do you impute it or drop it?

Part of Pro
37

Once you have found outliers, how do you decide what to do with them?

Part of Pro
38

What are the main families of feature selection methods, and how do they differ?

Part of Pro
39

What are filter methods in feature selection, and when do they fit best?

Part of Pro
40

What are wrapper methods, and how does recursive feature elimination work?

Part of Pro
41

How do embedded methods like Lasso select features while the model trains?

Part of Pro
42

What is the difference between feature selection and feature extraction?

Part of Pro
43

How should a feature's correlation with the target guide your selection?

Part of Pro
44

Given size and rooms in housing data, how would you build interaction features?

Part of Pro
45

How would you engineer features from customer purchase history to predict churn?

Part of Pro
46

How do you apply several aggregation functions at once to grouped data?

Part of Pro
47

Two DataFrames share a non-key column name - what does merge do?

Part of Pro
48

What causes SettingWithCopyWarning in pandas, and how do you fix it?

Part of Pro
49

What is the difference between a shallow and a deep copy in pandas?

Part of Pro
50

What is broadcasting in NumPy, and when do two shapes fail to align?

Part of Pro
51

When do you reach for map, apply, or applymap in pandas?

Part of Pro
Expert 7
52

What does data leakage look like in a time-series model?

Part of Pro
53

In production, what happens to values outside the range the min-max scaler saw?

Part of Pro
54

How would you engineer time-based features to catch fraudulent transactions?

Part of Pro
55

How do views and copies differ in pandas, and why does chained indexing break?

Part of Pro
56

What does Copy-on-Write change in pandas 3.0, and why was it introduced?

Part of Pro
57

What is the difference between apply and transform inside a groupby?

Part of Pro
58

How would you speed up a merge between two very large DataFrames?

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for Data Preparation & Feature Engineering? Send them this set.
Pro · $10/mo

50 of 58 Data Preparation & Feature Engineering answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git