insideout Get Pro
Learn
AI engineering · Module 01

Classical Machine Learning

Fit models to tables of data, and measure them honestly.

Start here · Lesson 01

Learning a function from examples

Features in, a label out, and a model whose numbers are fitted to data.

Start lesson

LessonsAll lessons

  1. 01 Learning a function from examplesFeatures in, a label out, and a model whose numbers are fitted to data. Free
  2. 02 Linear regressionFit a line by mean squared error, with gradient steps or one formula. Free
  3. 03 Training, validation and test setsKeep rows aside, so your score comes from data the model never saw. Free
  4. 04 Regularisation with L1 and L2Charge the model for big weights, and see which ones shrink or vanish. Pro
  5. 05 Logistic regressionTurn a weighted sum into a probability, then choose where to say yes. Pro
  6. 06 Measuring a classifierRead a confusion matrix, and set the threshold by what mistakes cost. Pro
  7. 07 Cross-validation and tuningPick settings on k folds, and keep the test set for the very end. Pro
  8. 08 Decision treesSplit the rows one question at a time until each group mostly agrees. Pro
  9. 09 Random forests and gradient boostingMany trees voting, or small trees that each fix the last one's mistakes. Pro
  10. 10 Preparing featuresScale numbers, encode categories and fill gaps inside one pipeline. Pro
  11. 11 Data leakageFind the columns and steps that let the answer slip into training. Pro
  12. 12 Clustering and PCAFind groups with k-means, and squeeze many columns into a few with PCA. Pro
  13. 13 Capstone: a tabular model end to endA churn table taken from raw columns to a tested model you could ship. Pro

Build it yourself · on your own machine

A marketing model on real bank data

A scikit-learn pipeline that picks which of a bank's customers to call about a term deposit, with its leak found and its score earned on rows it never saw.
  1. Download UCI's Bank Marketing data (bank-additional-full.csv: 41,188 calls, and whether each client opened a term deposit) and lock away a stratified 20% test set.
  2. Fit a quick model on every column, then find the leak: duration is the length of the call, known only once it's over, so drop it and fit again.
  3. Build one pipeline that scales the numbers and one-hot encodes the categories, and compare logistic regression with HistGradientBoostingClassifier by five-fold cross-validated ROC AUC.
  4. Tune the better model with RandomizedSearchCV, on the training rows only.
  5. Say a call costs $5 and a new deposit earns $50, let TunedThresholdClassifierCV pick the threshold that makes the most money, and only then score the test set, once.

How you'll know it worksTest ROC AUC of at least 0.78 with duration gone, within 0.02 of your cross-validated score, and more profit on the test rows at your threshold than from calling everyone.

Python, pandas and scikit-learn. The data is a free download from the UCI Machine Learning Repository, and everything runs on a laptop in minutes. Uses lessons 03 to 13.