Ch. 01
The ML Landscape
Supervised vs unsupervised vs RL, the metric-choice axis, the workflow vocabulary you'll execute on for the next 26 chapters.
A machine-learning algorithm is a program whose behavior is specified mostly by data, not by code. The line of code that turned this idea into the entire industry was written by Arthur Samuel in 1959: a checkers-playing program that improved by playing itself. Sixty-five years later, the same idea trains GPT-4 and AlphaFold. The taxonomy you'll memorize in this chapter (supervised vs. unsupervised vs. reinforcement, A small group of examples the model looks at together before making one adjustment to its numbers.Full glossary → vs. online, instance vs. model-based) is the standard one from Géron, but the thing that actually matters underneath all of it is much shorter: pick a function family, pick a loss, pick an optimizer, see what data your function ends up fitting. Every ML system in this curriculum is some variation on those four choices, and every failure mode is a place where one of those four choices was wrong.
FIG 01.1 · Learning outcomes
By the end of this chapter you will be able to:
- Classify a real-world ML problem along three axes (supervision, batch/online, instance/model) and pick the right algorithm family in under 60 seconds.
- Spot the difference between overfitting, underfitting, and a broken pipeline, by looking at a train-vs-validation loss curve.
- Explain why the test set is sacred and why touching it before deployment is the most common form of self-deception in ML practice.
- Read a confusion matrix and choose between accuracy, precision, recall, and F1 based on the costs of the two error types.
- Articulate three specific failure modes of ML systems (data leakage, distribution shift, feedback loops) and name a real-world deployment where each one bit.
- Read a paper abstract and locate the four choices: function family, loss, optimization procedure, data source.
FIG 01.2 · What you need first
- Ch 0 — Math & Python Prereqs — specifically the gradient descent intuition. Every algorithm here is "minimize a loss".
If you have written one for-loop and one function in Python, you can read this chapter. The code blocks are short and the libraries do the heavy lifting.
FIG 01.3.1
What machine learning is, defined precisely
Tom Mitchell's 1997 definition is the one researchers actually use:
A computer program is said to learn from experience with respect to some task and performance measure , if its performance on tasks in , as measured by , improves with experience .
That's three things: a task (), data (), a metric (). The reason this matters: when someone says "we trained a model", the right follow-up is always "on what data, with what metric, for what task?". Without those three, the claim is incomplete.
Géron sharpens it further: ML is useful when (a) traditional rule-based programming requires long lists of hand-tuned rules, (b) the rules change over time, or (c) you have data with structure but no human-articulable model of it. Spam filtering is the canonical example. The 1990s solution was rules ("contains the word VIAGRA, score 5"). The modern solution is to let a classifier learn the rules from labeled examples, and to retrain it weekly as spammers adapt.
FIG 01.3.2
The three supervision regimes
ML algorithms split, first and most importantly, by what their training data looks like.
Teaching a model from examples where you already know the right answer for each one.Full glossary →. Every training example is a pair . You're given the inputs and the desired outputs. The model learns a function . Classification (discrete ) and regression (continuous ) are the two flavors. ImageNet classification, sentiment analysis, house-price prediction, named-entity recognition: all supervised. The dominant paradigm. The reason ML has a "data labeling" industry.
Letting a model find groupings or patterns in examples when nobody has told it the right answers.Full glossary →. Training data is only. No labels. The model has to find structure on its own. Clustering (group similar examples), density estimation (model ), dimensionality reduction (find a low-dim representation that preserves what matters). Word embeddings are unsupervised. Self-supervised pretraining (predict the next word) is technically supervised on a synthetic label derived from the data itself; people call it unsupervised anyway.
Reinforcement learning. The model (called an agent) interacts with an environment, takes actions, receives rewards, learns a policy that maximizes expected reward. No labels in the supervised sense; the reward signal is sparser and arrives after a delay. AlphaGo, robot control, recommendation-system bandits, RLHF on top of a pretrained LLM.
There are mixed regimes worth knowing the names of:
- Semi-supervised: a little labeled data plus a lot of unlabeled data.
- Self-supervised: derive labels from the data structure itself (BERT's masked language modeling).
- Active learning: the model picks which examples should be labeled next.
- Reusing a model that already learned general skills as a head start, then retraining just a little of it for a new, related task.Full glossary →: train on task A, fine-tune on task B.
Modern LLM training is a stack of these. Pretraining is self-supervised. Instruction-tuning is supervised. RLHF is reinforcement learning. Each stage builds on the last.
FIG 01.3.3
Batch vs. online learning
Orthogonal to the supervision axis: how the data arrives.
A small group of examples the model looks at together before making one adjustment to its numbers.Full glossary → (offline) learning. You have a fixed dataset. You train once. You deploy the trained model. To update, you collect new data, retrain from scratch (or from a A saved snapshot of a model partway through training so you can stop and pick up later.Full glossary →), redeploy. This is what every textbook example does. It is also what most production ML systems do, on a weekly or daily retraining cadence.
Online learning. The model updates as new data arrives. One example, or a small mini-batch, at a time. The model is always "live". Used for streaming systems where retraining from scratch is too slow (high-frequency trading), where storing all historical data is impossible (sensors), or where the data distribution changes fast enough that recent examples matter much more than old ones (recommendation systems on rapidly-shifting catalogs).
The hidden cost of online learning: it is much easier to break. A burst of bad data poisons the model immediately. Batch learning gives you a chance to review the dataset before training. Online learning does not. Most production "online" systems are actually mini-batch online with a short delay and a separate validation gate before the model goes live.
FIG 01.3.4
Instance-based vs. model-based
A third independent axis: how the model represents what it learned.
Instance-based. The model is the training data. To make a prediction, find the most similar training examples and copy or interpolate from their labels. k-Nearest Neighbors is the canonical case. Pros: zero training time, easy to update (just add new examples). Cons: prediction is slow ( per query unless you index), memory-hungry, sensitive to One piece of information about an example that the model looks at when making a guess.Full glossary → Rewriting your numbers so that very large measurements and very small ones are put on a comparable footing.Full glossary → (the features are the attributes of each input the model sees — the columns of your data), no compression of the data into knowledge.
Model-based. The training procedure produces a compact set of parameters that summarizes the training data. To predict, you evaluate , which is fast and constant-time. Linear regression, logistic regression, decision trees, neural networks: all model-based. Pros: fast Running a finished, trained model on new data to get answers, as opposed to training it.Full glossary →, parameters are interpretable (sometimes), the model captures structure beyond memorization. Cons: training is slow, capacity is limited by the model class, you need to choose the model class up front.
Almost everything in this curriculum is model-based. kNN shows up in another chapter as a A simple reference method you compare against to see whether a fancier approach is actually worth it.Full glossary → and again in another chapter (RAG) as the "retrieval" half.
FIG 01.3.5
The bias-variance trade-off
This is the central explanation of why models fail.
Imagine your model's prediction error decomposed:
A single number that gets added to every guess, the same amount no matter what the inputs are.Full glossary → is the error from your model being too simple to capture the true function. A linear model fitting a clearly nonlinear pattern has high bias.
Variance is the error from your model being too sensitive to the particular The batch of examples the model actually studies and learns from.Full glossary → you used. A high-degree polynomial that wiggles to hit every training point but produces wildly different predictions on different training sets has high variance.
Irreducible noise is everything else: noise in the labels, missing features, fundamentally random aspects of the world.
The trade-off: simpler models have higher bias, lower variance. More complex models have lower bias, higher variance. The sweet spot is the model class where the total error is minimized. This is why "throw more parameters at it" doesn't always work, and why "use a simpler model" doesn't always work either.
In practice:
- High bias = When a model is too simple to capture the real pattern, so it does poorly even on its own study examples.Full glossary →. Train loss and val loss are both high. Both are close together.
- High variance = When a model memorizes the quirks and flukes of its study examples instead of the real pattern, so it flops on anything new.Full glossary →. Train loss is low. Val loss is much higher.
Both have specific fixes (more capacity for underfitting, more A penalty added to the wrongness score that discourages the model from leaning on big, fussy numbers, nudging it to stay simple.Full glossary → or data for overfitting). Regularization means adding a penalty for model complexity to the loss, so the optimizer is pushed toward simpler functions that are less able to memorize the training set; another chapter goes through the specific forms in detail.
FIG 01.3.6
Train / validation / test: the sacred split
You never use the same data to train a model and to estimate its real-world performance. The reason is simple: training optimizes performance on the training data, which makes training-set performance an upper bound on How well the model handles brand-new examples it never studied.Full glossary →, not an estimate of it.
The standard split:
- Train set (~70-80%): used to fit parameters via The core routine of training: check which way is downhill, take a small step, and repeat until the guesses are good.Full glossary → or whatever your optimizer is.
- A separate batch of examples you check the model against while you're still tinkering, to see how it's doing.Full glossary → (~10-15%): used to pick hyperparameters (How big an adjustment the model makes to its numbers each time, after the gradient tells it which way to go.Full glossary →, A penalty added to the wrongness score that discourages the model from leaning on big, fussy numbers, nudging it to stay simple.Full glossary → strength, model architecture) — the settings you choose for the learning algorithm, as opposed to the parameters gradient descent fits for you. You look at it many times.
- A batch of examples you hide away and use only once at the very end to get an honest score.Full glossary → (~10-15%): used to estimate real-world performance. You look at it once, at the very end, after every A setting you pick yourself before training starts, like the learning rate, batch size, or number of layers, which the model does not learn on its own.Full glossary → is fixed.
The test set is the most-violated rule in ML practice. Every time someone reports a final test The share of guesses the model got right out of all its guesses.Full glossary → and then says "let me tweak the model and try again", they are leaking the test set into the model selection process. The test number becomes an overestimate of real-world performance. Multiply that across thousands of papers and you get the Being able to run the same code again and get exactly the same result.Full glossary → crisis.
For small datasets, k-fold cross-validation generalizes the train/val split: divide the data into folds, train times each holding one fold as validation, average the validation scores. sklearn.model_selection.KFold is the standard tool.
from sklearn.model_selection import train_test_split
# Single split (good for large datasets)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
X_train, X_val, y_train, y_val = train_test_split(X_train, y_train, test_size=0.15, random_state=42)
# K-fold cross-validation (good for small datasets)
from sklearn.model_selection import cross_val_score
scores = cross_val_score(model, X, y, cv=5, scoring='accuracy')
print(f"CV accuracy: {scores.mean():.3f} +/- {scores.std():.3f}")FIG 01.3.7
Data leakage: the silent overfitter
When hints about the answers sneak into the studying, making the model look smarter than it really is.Full glossary → is what happens when information from outside the The batch of examples the model actually studies and learns from.Full glossary → sneaks into the training process. The model looks great on validation. It fails in production. The textbook examples:
- Future leakage: a One piece of information about an example that the model looks at when making a guess.Full glossary → in the training set is computed using data from the future relative to the prediction time. Example: predicting customer churn next month using "total revenue this year" as a feature, when "this year" includes future months.
- Target leakage: a feature is a proxy for the target. Example: predicting whether a patient has a disease using "hospital department they were admitted to", when the diagnostic department is highly correlated with the diagnosis.
- Train-test contamination: the same example, or a near-duplicate, appears in both train and test. Common with image datasets that have multiple crops of the same scene, or with web-scraped datasets where the same Wikipedia article appears multiple times.
- Preprocessing leakage: you compute normalization statistics on the full dataset before splitting. The mean and std of your features now depend on the A batch of examples you hide away and use only once at the very end to get an honest score.Full glossary →. Fix: fit the scaler on train only, then transform train, val, and test with the same fitted scaler.
from sklearn.preprocessing import StandardScaler
# WRONG: leaks test statistics
X_all = scaler.fit_transform(X_all) # then split
# RIGHT: fit on train only
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_val = scaler.transform(X_val)
X_test = scaler.transform(X_test)The pipeline pattern (sklearn.pipeline.Pipeline) exists specifically to prevent this kind of leakage by composing preprocessing and modeling into one fittable object.
FIG 01.3.8
Picking the right metric
The share of guesses the model got right out of all its guesses.Full glossary → looks like an obvious choice. It is often the wrong one.
For binary classification with class imbalance, accuracy is misleading. If 99% of your data is class 0, predicting class 0 always gives 99% accuracy. The model has learned nothing. You need the full A small table that splits the model's calls into four boxes: correct yeses, false alarms, correct nos, and misses.Full glossary →:
| predicted 0 | predicted 1 | |
|---|---|---|
| actual 0 | TN (true neg) | FP (false pos) |
| actual 1 | FN (false neg) | TP (true pos) |
From which:
- Out of all the times the model shouted 'yes,' how often it was actually right.Full glossary → = — of the things I predicted positive, how many really are?
- Out of all the things that really were 'yes,' how many the model managed to catch.Full glossary → = — of the things that really are positive, how many did I catch?
- F1 = — the harmonic mean of P and R, useful when both matter.
- ROC-AUC = the area under the receiver operating characteristic curve. Measures the model's ability to rank positives above negatives at varying thresholds. Threshold-free.
Which to use. It depends on the cost of each error.
- Cancer screening: false negatives are catastrophic, false positives are merely inconvenient. Optimize recall.
- Spam filtering: false positives (real emails marked spam) are worse than false negatives. Optimize precision.
- Information retrieval: rank quality matters. Optimize AUC or precision@k.
- Fraud detection: depends. Sometimes you need a precision-recall curve at multiple operating points.
For regression: MSE (mean squared error) penalizes large errors quadratically. MAE (mean absolute error) is robust to outliers. R² is the fraction of variance explained, normalized so a constant predictor scores 0 and a perfect predictor scores 1.
another chapter will go through all of these in code.
FIG 01.3.9
The standard ML workflow
Géron's checklist (06-practice/geron-ml-project-checklist) lists eight steps that every ML project follows. Memorize them.
-
Frame the problem. What is the business or research goal? What does "good" look like? What is the current A simple reference method you compare against to see whether a fancier approach is actually worth it.Full glossary → (heuristic, manual process, simpler model)? If you cannot answer these three questions, you are not yet ready to write code.
-
Get the data. Find it, download it, document its provenance. Check licenses. Save a snapshot of the exact version you used (raw bytes, not "we used the Kaggle dataset").
-
Explore the data. Plot histograms of every One piece of information about an example that the model looks at when making a guess.Full glossary →. Plot pairwise scatter for the most important features against the target. Look at the labels. Compute summary statistics. Find the weirdness. This is where you discover that 5% of your "income" feature is the value -999, used as a missing-value indicator.
-
Prepare the data. Clean. Impute missing. Encode categoricals. Scale numerics. Engineer features. Pipeline everything so it's reproducible.
-
Try several models. Pick three or four candidate model families. Train each. Compare on A separate batch of examples you check the model against while you're still tinkering, to see how it's doing.Full glossary →. Do not yet tune.
-
Fine-tune the best model. A setting you pick yourself before training starts, like the learning rate, batch size, or number of layers, which the model does not learn on its own.Full glossary → search (grid, random, Bayesian). Look at errors. Engineer more features. Iterate.
-
Present the solution. Write down what you did, what worked, what didn't. Sanity-check on the A batch of examples you hide away and use only once at the very end to get an honest score.Full glossary →. Once.
-
Launch, monitor, maintain. Deploy. Set up monitoring for input When the data a model meets in the real world differs from the data it trained on, so it stumbles.Full glossary →, output distribution shift, and downstream metric degradation. Plan for retraining cadence.
another chapter walks through all eight on a real housing-price dataset.
FIG 01.3.10
The end-to-end ML system view
A trained model is one component of an ML system, not the whole thing. The system also contains:
- Data pipeline: how raw data becomes training-ready features (ETL, One piece of information about an example that the model looks at when making a guess.Full glossary → stores, schema validation).
- Training infrastructure: where the model trains (Colab notebook, SageMaker, internal GPU cluster), how runs are tracked (MLflow, Weights & Biases, plain CSVs).
- Serving infrastructure: where the model runs at Running a finished, trained model on new data to get answers, as opposed to training it.Full glossary → (REST API, A small group of examples the model looks at together before making one adjustment to its numbers.Full glossary → job, on-Where a piece of data lives and gets worked on: the main processor or the faster graphics chip.Full glossary →).
- Monitoring: dashboards for When the data a model meets in the real world differs from the data it trained on, so it stumbles.Full glossary →, latency, error rates.
- Retraining loop: when and how the model gets updated.
The Made-With-ML curriculum splits these out explicitly. Huyen Chip's Designing ML Systems and Eugene Yan's posts hammer on the same point: in production, the model is 10% of the code and 5% of the bugs.
another chapter (MLOps) covers all of this. For now, the lesson is just: when you read about an ML system in the news, the headline is the model, but most of the actual engineering work is elsewhere.
FIG 01.3.11
The eight ways ML deployments fail
The model trains fine. The val The share of guesses the model got right out of all its guesses.Full glossary → is good. You ship it. Then:
-
When the data a model meets in the real world differs from the data it trained on, so it stumbles.Full glossary →: production data looks different from training data. Maybe seasons changed. Maybe a new product was launched. Maybe COVID happened. The model is fine; the world moved.
-
Concept drift: the relationship between inputs and labels changes. Spammers adapt. Fashion changes. Users learn the system and game it.
-
Feedback loops: the model's predictions influence the data it will see next. A recommender that pushes popular items creates more popularity for those items, which the next training run sees as "users love popular items". Self-reinforcing A single number that gets added to every guess, the same amount no matter what the inputs are.Full glossary →.
-
Adversarial inputs: someone discovers inputs your model handles badly, on purpose. Image classifiers fooled by sticker patches. LLMs jailbroken by adversarial suffixes. Once the existence of an attack is public, the attack becomes part of your real input distribution.
-
Label drift: the labelers' standards change. The 2023 hate-speech labeling guidelines differ from the 2024 ones. Your The batch of examples the model actually studies and learns from.Full glossary → is now stale.
-
Underspecification: the training objective is consistent with many possible models, only some of which generalize well. You shipped the version of the model that happened to memorize a spurious correlation.
-
Operational silent failure: the model returns reasonable-looking outputs on garbage inputs. Nobody notices. This is the most common failure mode. The fix: alerting on input distribution, not just output distribution.
-
Ethical failure: the model performs unequally across demographic groups. ImageNet's "wedding" class was overwhelmingly Western. Face recognition systems had higher error rates on darker skin. These are not abstract; they have shipped, and they have caused harm. another chapter covers this in depth.
The list is from the fastbook ethics chapter (13-fastbook/03_ethics) merged with Huyen Chip's production-failures post and Eugene Yan's "what could go wrong" framework.
FIG 01.3.12
A picker for "which algorithm should I try first"
A pragmatic flowchart. Use it for ≈80% of new problems before reaching for anything fancier.
Tabular data, classification or regression.
- Start:
sklearn.ensemble.GradientBoostingClassifierorxgboost.XGBClassifierorlightgbm.LGBMClassifier. Trees on tabular data are still state of the art. - A simple reference method you compare against to see whether a fancier approach is actually worth it.Full glossary →:
sklearn.linear_model.LogisticRegression(classification) orLinearRegression(regression). If A signal showing which direction to change each of the model's numbers to make its mistakes BIGGER, so you go the opposite way to make them smaller.Full glossary → boosting doesn't crush this baseline, your features need work. - Iterate from there.
Images.
- Start: a pretrained vision backbone (
torchvision.models.resnet50or a ViT) with a new classifier head. Fine-tune. - Baseline: a simple CNN trained from scratch. If it beats pretrained, something's weird.
- another chapter.
Text.
- Start: a pretrained transformer (
transformers.AutoModel) with a task-specific head. For classification, embed + logistic regression often works. - Baseline: TF-IDF + logistic regression. Frequently competitive. 15.
Sequences / time series.
- Start: gradient boosting on engineered features (lag features, rolling stats).
- Then: LSTM or Transformer with explicit time encoding.
- another chapter.
Tiny dataset.
- k-NN, naive Bayes, or a heavily-regularized linear model. Stop. More data first.
No labels.
- Cluster (k-means, DBSCAN) and inspect the clusters with a human. Or train a self-supervised representation and use those embeddings downstream.
- another chapter.
FIG 01.3.13
What "deep learning" changes about this picture
Everything I've written is true for classical ML. Deep learning changes three things, not all of them.
It changes the function family: from "linear in features" or "tree" to "deep neural network with millions or billions of parameters". This lets you skip One piece of information about an example that the model looks at when making a guess.Full glossary → engineering for images, text, and speech, because the network learns features.
It changes the data regime: deep models need a lot more labeled data, or a lot of cheap unlabeled data plus a clever pretraining objective.
It does not change the workflow. You still split train/val/test. You still pick a loss. You still track training and validation curves. You still measure error analysis on held-out examples. The fastbook chapter 13-fastbook/01_intro calls this out explicitly: deep learning is not magic, it is the same Teaching a model from examples where you already know the right answer for each one.Full glossary → loop with a bigger function family.
The downstream chapters take this for granted. By another chapter you'll be training neural networks. The reason it's worth stating up front: the The fixed set of all chunks a model is allowed to read or produce.Full glossary → in this chapter (loss, A signal showing which direction to change each of the model's numbers to make its mistakes BIGGER, so you go the opposite way to make them smaller.Full glossary →, train/val/test, When a model memorizes the quirks and flukes of its study examples instead of the real pattern, so it flops on anything new.Full glossary →, metric) survives unchanged into the deep learning chapters. You are not learning a separate framework. You are learning more of the same.
FIG 01.3.14
Reading code: where to look first in a new ML repo
A practical skill that nobody teaches explicitly. When you open a new ML repository, here is where to look, in order.
README.md— find the one paragraph that explains what the model does and what dataset it trains on.- The script that trains the model. Often
train.pyormain.py. Find the line that callsloss.backward. The model class is upstream of that line. The dataset is upstream of that line. - The model class. Read
__init__for what the parameters are. Readforwardfor the function family. - The data loader. Read
__getitem__for what one training example looks like. Read the transforms applied to it. - The A rule that turns one bad guess into a single number measuring how far off it was, where lower is better.Full glossary →. Often hidden inside
forwardor computed intrain.py. Find theF.cross_entropycall or equivalent. - The hyperparameters. Usually in a
config.yamlor argparse defaults. Note: How big an adjustment the model makes to its numbers each time, after the gradient tells it which way to go.Full glossary →, A small group of examples the model looks at together before making one adjustment to its numbers.Full glossary → size, total steps, Starting training with tiny steps that grow for a little while before the main plan kicks in.Full glossary → steps, Gently nudging a model's weights toward smaller values to keep the model simpler and less likely to overfit.Full glossary →. These are the five hyperparameters that determine 80% of training outcomes.
Karpathy's nanoGPT (12-karpathy-code/nanoGPT-master-model + nanoGPT-master-train) is laid out exactly this way and is worth opening as a reference point. By another chapter you'll be reading it line by line.
FIG 01.4 · Safety lens · this chapter
The three-axis taxonomy in this chapter (supervision, A small group of examples the model looks at together before making one adjustment to its numbers.Full glossary →/online, instance/model) is value-neutral, but the choices you make along those axes have safety consequences that are obvious in retrospect and ignored in practice. Three failure modes, each tied to a specific decision you'll make in chapters 2-25.
The "we'll fix it in retraining" anti-pattern. When you build an online-learning system, the implicit promise is that the model adapts to new data faster than failures compound. The 2016 Microsoft Tay incident is the canonical example: an online-learning chatbot exposed to adversarial input on Twitter learned to produce racist content within 16 hours. The fix is not technical sophistication; it is procedural. Production ML systems that update online should have human-in-the-loop validation gates, rate limits on One of the model's internal numbers that gets adjusted as it learns.Full glossary → updates, and rollback capability to a known-good A saved snapshot of a model partway through training so you can stop and pick up later.Full glossary →. See 06-practice/madewithml-mlops-monitoring §online-failure-modes and 13-fastbook/03_ethics §case-studies for documented incidents. The deeper lesson: a system that learns continuously is a system that can be poisoned continuously.
When the data a model meets in the real world differs from the data it trained on, so it stumbles.Full glossary → as the default state of the world. Every model you train assumes its test distribution matches its training distribution. This assumption is true in the lab and false in deployment. Medical-imaging models trained on one hospital's scanners systematically underperform on another hospital's scanners (Zech et al. 2018). Credit-scoring models trained pre-pandemic produced miscalibrated predictions post-pandemic. The safety habit: explicitly model the distribution-shift assumption every time you ship a model. Log the input distribution. Compare it to the training distribution daily. Set thresholds for "the model is now operating out of distribution and predictions should be flagged". See 06-practice/lilianweng-posts-2024-07-07-hallucination §calibration and 05-safety/anthropic-research-core-views-on-ai-safety §robustness.
Feedback loops compound discriminatory outcomes. This is the failure mode that ML ethicists have been writing about for a decade and that production teams keep rediscovering. A predictive policing model that sends more police to neighborhoods with more recorded crimes will produce more recorded crimes in those neighborhoods, which becomes training data for the next iteration. The original disparate predictions are amplified, not corrected. The fastbook ethics chapter walks through the COMPAS case (13-fastbook/03_ethics §propublica-compas); the AI Safety Book chapter on A single number that gets added to every guess, the same amount no matter what the inputs are.Full glossary → (20-aisafetybook/fairness if available) goes deeper. The safety habit: when you train a model that produces decisions that affect people, audit the per-subgroup error rates before deployment, and again every retraining cycle. sklearn.metrics.classification_report segmented by demographic is a five-line check that prevents an entire class of harm.
The habits to adopt before you ship anything from chapters 2-25:
- Always log your input distribution. A 5-minute Jupyter cell that compares deployed inputs to training-set inputs catches an entire class of silent failures.
- Always compute per-subgroup metrics. Aggregate The share of guesses the model got right out of all its guesses.Full glossary → is the metric you report. Per-subgroup metrics are the metric you debug from.
- Always have a rollback procedure. The first time you ship a model that needs rolling back, you will appreciate the procedure existing.
FIG 01.6 · Chapter notebook
Build this chapter with your own hands
A single self-contained notebook. You implement the ideas, check yourself against assert cells as you go, then finish with a capstone. Hint ladders and folded solutions throughout, so it runs top-to-bottom even before you fill anything in.
What you'll build
- A life-satisfaction-vs-GDP model on a tiny vendored dataset, fit two ways: instance-based (k-NN) and model-based (a line), checked against scikit-learn.
- The sampling-bias reveal: a line that fits a hand-picked slice of countries beautifully, then collapses the moment the poorer and richer countries are added back.
- The overfitting reveal: a high-degree polynomial that nails every training point and is useless off it, watched live on a train-vs-validation U-curve.
- An unsupervised clustering of the same countries with the labels hidden, and a learned decision boundary for "happy vs not", drawn as an image.
- A runnable three-axis problem classifier (supervision · batch/online · instance/model) that turns the chapter's taxonomy into code.
~1 min on CPU · 96 cells · 9 checked exercises · runs in Colab
FIG 01.7 · Going further
06-practice/geron-ml-project-checklisteight steps, three pages, used by every Géron reader. Bookmark.
08-geron-notebooks/01_the_machine_learning_landscapeGéron's full chapter, with code. Worth reading once after this distillation.
13-fastbook/01_introfast.ai's perspective. Less mathematical, more pragmatic. The contrast with Géron is instructive.
13-fastbook/03_ethicsthe chapter to read before you ship anything.
06-practice/huyenchip-indexHuyen Chip's Designing ML Systems essays. The production-engineering view.
06-practice/madewithml-mlops-designMade-With-ML's full curriculum. The end-to-end ML systems book.
03-curricula/google-mlcc-indexGoogle's ML crash course. Different angle, very approachable.
18-lilian-weng/2017-06-21-overviewLilian Weng's overview post. Short, dense, well-cited.
02-code-refs/amidi-cs229-supervisedStanford's two-page cheat sheet on supervised learning algorithms. Print it.
FIG 01.8 · What this enables
Chapters you can now read, with the connecting idea written out.
You'll execute the eight-step workflow from this chapter on a real dataset (California Housing). The vocabulary is set; the practice happens next.
You'll dive into the confusion-matrix metrics, ROC, PR curves, and multi-class extensions. The "pick the right metric" theme expands into 12,000 words.
The production-failure modes I gestured at here get full chapters of their own.
FIG 01.9 · 24 sources
- 02-code-refs/amidi-cs229-ml-tips
- 02-code-refs/amidi-cs229-supervised
- 03-curricula/google-mlcc-classification
- 03-curricula/google-mlcc-index
- 04-stanford/cs229-main-notes-pdf
- 05-safety/anthropic-research-core-views-on-ai-safety
- 06-practice/geron-ml-project-checklist
- 06-practice/huyenchip-index
- 06-practice/lilianweng-posts-2024-07-07-hallucination
- 06-practice/madewithml-foundations-notebooks
- 06-practice/madewithml-home
- 06-practice/madewithml-mlops-design
- 06-practice/madewithml-mlops-monitoring
- 06-practice/madewithml-mlops-preparation
- 08-geron-notebooks/01_the_machine_learning_landscape
- 08-geron-notebooks/02_end_to_end_machine_learning_project
- 08-geron-notebooks/03_classification
- 08-geron-notebooks/10_neural_nets_with_keras
- 12-karpathy-code/nanoGPT-master-model
- 13-fastbook/01_intro
- 13-fastbook/02_production
- 13-fastbook/03_ethics
- 18-lilian-weng/2017-06-21-overview
- 24-founder-blogs/karpathy-recipe