AI & ML Quick Path Progress

All cheat sheets

Part 2 cheat sheet: data

Most of the work in a real project is data. This is the short list.

Data, features and labels

  • A row is one example. Features are the columns the model reads; the label is the column you want to predict.
  • Only use features you will really have at prediction time.

The three sets

  • Training set: the model learns from it.
  • Validation set: compare ideas and settings.
  • Test set: open once, at the end, like a final exam.
  • Split before any training, and for data over time split by time.
Three cards joined by arrows: the training set is the practice questions the model learns from, the validation set is a mock exam used to compare ideas and settings, and the test set is the final exam, opened once at the very end and shown with a padlock. Below them a bar shows an illustrative split of 70 percent training, 15 percent validation and 15 percent test. Training set Practice questions The model learns from it. Validation set Mock exam Compare ideas and settings. Test set Final exam Open once, at the very end. The split is made before any training. Illustrative sizes (as in the maths box): Train 70% Validation 15% Test 15% Never tune the model on the test set: it stops being a fair final exam.
Practice questions, a mock exam, then one final exam. The split is made before any training, and the test set is never used for tuning.

Four kinds of mess

  • Missing values, duplicates, messy categories, and invalid values or outliers.
  • Look at the data first (charts and summaries), then clean with a script you keep.
  • Mean and median can differ a lot when there are outliers.
A small made-up table of customers with highlighted problems: an empty city cell, a duplicated row for Ana, the city London written as london, and waiting times of minus 3 and 2000 minutes. Labels on the right name them: missing value, duplicate row, messy category, invalid value or outlier. customer city age wait (min) Ana London 34 12 Ben (empty) 29 9 Ana London 34 12 Cy london 41 -3 Di Leeds 38 2000 Missing value (empty) city Duplicate row Ana appears twice Messy category London / london Invalid or outlier -3 or 2000 min A small made-up table with four kinds of mess Clean it before you train: fix, fill or remove each problem, and keep a record of what you changed.
Missing values, duplicates, inconsistent categories and invalid values are the four kinds of mess to find and fix before training.

Collecting and labelling

  • Label with a written guide, let two people label the same items, and measure how often they agree.
  • SQL is the everyday tool for pulling rows from a database.

Features from raw data

  • Turn text categories into numbers (one-hot: one 0/1 column per category).
  • Scale numbers when columns have very different sizes.
  • Fit encoders and scalers on training data only, then apply them everywhere.
On the left a table with one column called plan holding basic, pro and team. An arrow labelled one-hot leads to a table with three columns, plan basic, plan pro and plan team, where each row has a single 1 and two 0s. Before: one text column plan basic pro team one-hot After: one yes/no column per plan plan_basic plan_pro plan_team 1 0 0 0 1 0 0 0 1 A model works with numbers, not words. One-hot encoding gives each category its own 0/1 column, so "pro" is not treated as "bigger" than "basic". One column became three, as in the lesson's run. Fit the encoder on the training data only, then apply it everywhere (see the leaky and safe preparation diagram).
One text column becomes one yes/no column per plan, so the model does not treat pro as bigger than basic.

Leakage

  • Leakage is when the model sees something at training time that it will not have in real use.
  • It makes results look better than they are. Split first, prepare after.