Skip to main content
← AI & Machine Learning Study Guide

Unit 2 · Where the effort is

Data Preparation and Features

The unit that decides whether a project succeeds. A model can only learn what its data contains, including the data errors and the historical bias.

What a strong answer looks like

A strong Unit 2 answer says what was done about missing values and encoding, and justifies each choice rather than reporting it.

Topics in this unit

1

Data Quality

Know

A model reproduces the relationships in its training data, including systematic errors. No algorithm recovers information the data never held.

Apply

Inspect shape, types, missing counts, and class balance before modelling.

Watch out

Assuming clean data. Real datasets have gaps, duplicates, and wrong types by default.

Study move

Profile a dataset and list every problem you find before touching a model.

2

Features, Labels, and Leakage

Know

Leakage is a feature that would not exist at prediction time, or that encodes the answer. It produces excellent scores and a useless model.

Apply

For each feature, ask whether it is available at the moment the prediction must be made.

Watch out

A cancellation date in a churn model, which is present only for customers who already churned.

Study move

Mark each column of a dataset as feature, label, or leaking, with a reason.

3

Encoding and Scaling

Know

Integer codes imply an order categories may not have, so unordered categories are one-hot encoded. Distance-based algorithms need features on comparable scales.

Apply

One-hot unordered categories; scale features before any distance-based method.

Watch out

Fitting a scaler before splitting, which lets test statistics influence the transformation.

Study move

State the correct order of split, fit, and transform, and what breaks if reordered.

4

Missing Data

Know

Every handling choice changes the result. Dropping rows can remove exactly the group under study; imputing with a constant distorts a distribution.

Apply

Choose a documented strategy and report it alongside the result.

Watch out

Replacing missing values with zero without checking whether zero is a meaningful value in that column.

Study move

Report missing counts per column and justify one handling choice.

Emphasized in this unit

Connections and techniques that receive extra attention in this unit.

  • Profiling before modelling
  • Hunting leakage feature by feature
  • Splitting before fitting any transformation

Varies by course

Related topics some schools attach to this unit and others leave out. Covered on request rather than assumed.

  • Feature engineering depth. Some sections spend heavily here.
  • Imputation methods. Beyond simple strategies varies by course.

Mastery checklist

  • Profile a dataset for shape, types, gaps, and balance.
  • Identify a leaking feature and explain why.
  • One-hot encode unordered categories.
  • Order split, fit, and transform correctly.

Check yourself

  • Why is a cancellation date a leaking feature in a churn model?
  • Why does integer encoding mislead a model?
  • What can dropping rows with missing values destroy?

Modeling drill

Given a dataset predicting exam success, list usable features, name one leaking column, and state your missing-value strategy with a reason.

FeatureLabelLeakageOne-hot encodingScalingImputationClass balance