Semester 1 · Week 08
The lifecycle, and choosing a supervised model
- Ch 10 The Data Science Lifecycle
- Ch 11 Supervised Learning: Overview of Approaches
Chapter 10: The data science lifecycle
A loop walked many times, not a road walked once.
Notes · slide 2
Time: 50 minutes for two chapters. About 20 on Chapter 10, 25 on Chapter 11, and 5 to check understanding.
Say: You have the pieces: framing, maths, cleaning, SQL, and EDA. Tonight is how they fit into a project, then the first look at models.
Say: Most data science failures aren't algorithmic. They're process failures. A model built on the wrong data version. Three weeks tuning before anyone checked the baseline. A model that degrades unseen for six months.
Key line: a loop walked many times, not a road walked once.
Next: the stages.
Eight stages
| Stage | Where it lives |
|---|---|
| 1. Problem framing | Chapter 2 |
| 2. Data collection and understanding | Chapters 7–9 |
| 3. Data preparation | Chapters 7, 14 |
| 4. Modelling | Chapters 11–20 |
| 5. Evaluation | Chapters 13, 16 |
| 6. Deployment | Book 2 |
| 7. Monitoring | Book 2 |
| 8. Iteration | Back to stage 1 |
Notes · slide 3
Say: Framing, data understanding, preparation, modelling, evaluation, deployment, monitoring, and iteration. The right-hand column shows where each lives in the course. Deployment and monitoring are Book 2, Semester 2.
Say: Evaluation is against the success metric from stage 1, the business metric, not just accuracy.
Ask: "Which stages have we covered so far?" Listen for: framing, understanding, and preparation. Modelling starts tonight.
Next: two industry frameworks.
Two frameworks
- CRISP-DM: business understanding, data understanding, preparation, modelling, evaluation, deployment. The most cited.
- TDSP, Microsoft's Team Data Science Process: adds deployment, monitoring, and governance as first-class stages.
This series follows TDSP's operational emphasis. That's where a solutions architect adds the most.
Notes · slide 4
Say: CRISP-DM is the most cited. Six stages from business understanding to deployment. Microsoft's Team Data Science Process adds deployment, monitoring, and governance as stages in their own right.
Say: This series follows TDSP's emphasis on operations. That's where a solutions architect adds the most: the stages CRISP-DM treats lightly.
Key line: use the frameworks as shared vocabulary and a checklist, not as gates to clear in order.
Next: what the diagrams leave out.
Why the textbook diagram lies
- Every diagram is a left-to-right pipeline with one arrow back.
- In practice, EDA breaks the problem statement: the label doesn't exist, or the class balance makes the metric impossible.
- Evaluation sends you back to features. Monitoring sends you back to framing.
Loop-backs are the norm, not a failure.
Notes · slide 5
Say: Every diagram runs left to right with one arrow back at the end. Real projects loop back constantly. EDA breaks the problem statement: the label doesn't exist, or the class balance makes the metric impossible. Modelling sends you back to features. Evaluation reveals the business cared about a different metric. Monitoring starts the next project.
Key line: loop-backs are the norm, not a failure. Know which stage you're in.
Ask: "When have you had to go back a stage on a project?" Collect one story.
Next: where projects die.
Where projects die
- Deployment is the stage most projects never reach.
- Most prototypes never make it to production.
- "It runs in a notebook" and "it's a reliable production system" are different bars.
Notes · slide 6
Say: Every stage has a failure mode. The most common in industry is deployment. The model works in a notebook, nobody builds the serving path, and it never reaches production. Surveys keep finding that most prototypes never ship.
Key line: "it runs in a notebook" and "it's a reliable production system" are different bars. Engineers in the room already know that from software.
Say: That's why Semester 2 opens with deployment, MLOps, and monitoring.
Next: how much process.
Process versus speed
- Formal frameworks help with stakeholders and audits.
- Too much upfront framing is its own failure mode.
- Robertson and Robertson size the process to the project: rabbit, horse, or elephant. Horse is the default.
Notes · slide 7
Say: Frameworks help with stakeholders and audits. Followed rigidly, they slow you down. Too much upfront framing is its own failure. You can't know what's realistic until you've seen the data.
Say: Robertson and Robertson size the process: rabbit, horse, or elephant. A rabbit is small and fast, learning from working increments. An elephant needs a complete formal specification. The book argues data science projects should be rabbits wherever possible.
Say: Waterfall was never meant to be rigid. Royce's 1970 paper didn't use the word and asked for feedback loops.
Next: the project charter.
The project charter
Procedure 10.1. A one-page companion to the Chapter 2 problem statement:
- an owner for each stage
- a pre-mortem: assume it failed, then list why
- kill criteria: when to stop, before sunk cost decides for you
Notes · slide 8
Say: Procedure 10.1 is one page, next to the Chapter 2 problem statement. An owner for each stage. A pre-mortem: imagine the project has failed, then list why. Kill criteria: the conditions under which you stop.
Key line: without kill criteria, a project survives on sunk cost.
Ask: "Write one kill criterion for a churn model." Listen for: something measurable, such as "stop if precision at 60% recall is below 0.3 after two feature passes".
Next: the worked example.
Worked example: churn, end to end
The Chapter 2 telco problem, through all eight stages.
- Target: precision ≥ 0.40 at recall ≥ 0.60.
- 8,000 synthetic customers, 7.0% churn.
- Split first, then fit the scaler on training data only.
- Baseline "never churns": 93% accuracy, zero churners caught.
Notes · slide 9
Say: The Chapter 2 telco problem through all eight stages. The contract: precision at least 0.40 at recall at least 0.60. 8,000 synthetic customers, 7% churn.
Say: Split first, then fit the scaler on training rows only. Then two baselines before any model. "Never churns" scores 93% accuracy and catches nobody.
Key line: always beat a baseline before you trust a model.
Next: what happened.
Worked example: the model fails its contract
- Logistic regression with class weights: AUC ≈ 0.638.
- The threshold for recall ≥ 0.60 is ≈ 0.493.
- Precision there: ≈ 0.103. Far short of 0.40.
- It flags 661 of 1,600 customers.
The model doesn't meet the business contract. Loop back to stage 3 for better features.
Notes · slide 10
Say: Logistic regression with class weights reaches AUC 0.638. To get recall to 0.60, the threshold drops to about 0.49. Precision there is about 0.10, far short of 0.40. It flags 661 of 1,600 customers.
Key line: the model doesn't meet the contract. The right move is back to stage 3 for better features, or to stage 1 to renegotiate. Not on to deployment.
Say: This is a realistic first pass. Praise the honesty. A good-looking AUC isn't what was agreed.
Next: the chapter in one idea.
Mental model
- Know which stage you're really in, not which stage you think you're in.
- Great metrics nobody agreed on? You're still in stage 1.
- In production with nobody watching? You're not done. You just haven't noticed you're back at the start.
Notes · slide 11
Say: Know which stage you're really in. Great metrics nobody agreed on mean you're still in stage 1. A model in production with nobody watching isn't done. You're back at the start and haven't noticed.
Next: Chapter 11, choosing a model.
Chapter 11: Supervised learning
Given this data and this constraint, what's the first thing worth trying?
Notes · slide 12
Time: about 25 minutes for this chapter.
Say: Every supervised algorithm learns a mapping from labelled examples to answers. Dozens of families claim to do it. None wins every time.
Key line: the question is practical. Given this data and this constraint, what's the first thing worth trying?
Next: what each family assumes.
Inductive bias
Every algorithm family assumes a shape for the relationship.
- A line or hyperplane.
- A maximum-margin boundary.
- A set of if/else splits.
- A neighbourhood vote.
- A product of per-feature likelihoods.
Pick the family whose assumption matches your data.
Notes · slide 13
Say: Every algorithm assumes a shape for the relationship. A line or hyperplane. A widest-margin boundary. A set of if/else splits. A neighbourhood vote. A product of per-feature probabilities.
Say: There's no assumption-free algorithm. Choosing one is choosing what you believe about the data.
Key line: pick the family whose assumption matches the data.
Ask: "House price rising steadily with floor area. Which family?" Listen for: linear.
Next: the trade-off behind every choice.
The bias-variance trade-off
Expected test error=Bias2+Variance+Irreducible error
- Bias: wrong assumptions. A line through a curve stays wrong with any amount of data.
- Variance: sensitivity to the sample. A memorising model changes with every new sample.
- Irreducible error: noise. No model removes it.
Simple models: high bias, low variance. Flexible ones: the reverse.
Notes · slide 14
Say: Test error has three parts. Bias: wrong assumptions. A line through a curve stays wrong with any amount of data. Variance: sensitivity to the sample. A model that memorises changes with every new sample. Irreducible error: noise no model removes.
Say: Complexity is a dial. Simple models have high bias and low variance. Flexible models have the reverse. Where the minimum sits depends on the data. Chapter 13's cross-validation finds it.
Ask: "Training accuracy 99%, test 70%. Which one?" Listen for: variance. It's overfitting.
Next: the families, one at a time.
Linear models and SVMs
- Linear regression fits a straight line.
- Logistic regression is a classifier. It outputs probabilities, often well calibrated.
- SVMs choose the separating hyperplane with the widest margin. Kernels bend the boundary.
- All need feature scaling.
Notes · slide 15
Say: Linear regression fits a straight line. Logistic regression is a classifier despite its name. Its outputs are probabilities, often well calibrated. Train a linear baseline first. If a complex model can't beat it, the problem is the features or the data.
Say: An SVM picks the separating hyperplane with the widest margin. Only the closest points, the support vectors, decide where it sits. A kernel lets it draw a curved boundary. SVMs train slowly past tens of thousands of rows.
Say: All of these need scaled features.
Next: how logistic regression makes a probability.
The sigmoid

Logistic regression squeezes a linear score into a probability between 0 and 1.
Notes · slide 16
Say: The sigmoid squeezes any number into 0 to 1. Large positive scores go towards 1, large negative towards 0. A score of zero gives exactly 0.5.
Say: It's steep in the middle and flat at the ends. Near zero, a small change in the score swings the prediction. Once the model is confident, extra evidence barely moves it.
Say: The 0.5 point is where the default threshold sits. Week 12 shows why you'd move it.
Next: the other families.
Trees, neighbours, and Naive Bayes
- Decision trees: readable, no scaling needed, high variance when deep.
- KNN: no assumed shape. Slow to predict, and needs scaling. Suffers the curse of dimensionality.
- Naive Bayes: assumes independent features given the class. Rarely true, works anyway. Fast, a strong text baseline.
Notes · slide 17
Say: A decision tree splits on one feature at a time. You can print it and read it like a flowchart, and it needs no scaling. Deep trees memorise. Chapter 12's ensembles fix that.
Say: KNN votes among the closest training points. No assumed shape. But every prediction measures distance to every training point, so it's slow. In many dimensions, everything is roughly equally far away. And it needs scaling.
Say: Naive Bayes assumes features are independent given the class. Rarely true. It works anyway, and it's a fast, strong text baseline.
Next: is there a best algorithm?
No free lunch
- Averaged over all possible problems, no algorithm beats any other.
- That rules out a universal favourite.
- It doesn't stop some algorithms winning on the problems that come up in practice.
- On tabular data, gradient-boosted trees usually win. That's next week.
Notes · slide 18
Say: Averaged over every possible problem, no algorithm beats any other. That rules out a universal favourite.
Say: It doesn't stop some algorithms winning on the problems that come up in practice. Real data has structure. Tabular data favours gradient-boosted trees. Images and text favour deep learning.
Say: The worked example makes it concrete. On two concentric circles, logistic regression scores 0.289. Random forest scores 1.000. Change the shape of the data and the ranking flips.
Next: six classifiers on one dataset.
Worked example: six classifiers
Breast cancer data: 569 tumours, 30 features.
| Algorithm | Test acc. | CV mean ± std | Predict time |
|---|---|---|---|
| Logistic regression | 0.982 | 0.980 ± 0.013 | 1.1 ms |
| SVM (RBF) | 0.982 | 0.971 ± 0.018 | 1.5 ms |
| KNN | 0.956 | 0.967 ± 0.021 | 35.4 ms |
| Random forest | 0.956 | 0.954 ± 0.023 | 5.8 ms |
| Naive Bayes | 0.930 | 0.932 ± 0.004 | 0.6 ms |
| Decision tree | 0.912 | 0.910 ± 0.019 | 0.9 ms |
Notes · slide 19
Say: Breast cancer data: 569 tumours, 30 numeric features. Six classifiers, 5-fold cross-validation, the same split for all.
Do: give the room a minute with the table before the next slide. Ask what stands out.
Say: Timings vary by machine. The scores are fixed by the seed.
Next: what to notice.
Worked example: what to notice
- The linear models win. Thirty clean clinical features suit a hyperplane.
- KNN's prediction time is the O(n) cost made visible.
- Naive Bayes has the most stable scores: low variance.
- Random forest misses 3 malignant tumours and wrongly flags 2 benign ones. The costlier error is the more common one.
Notes · slide 20
Say: Logistic regression and the SVM tie at the top. Thirty clean clinical features suit a hyperplane. KNN's predict time, 35.4 ms, is the cost of measuring distance to every training point. Naive Bayes has the steadiest scores, at ±0.004. Its strong assumption leaves less to overfit.
Say: Random forest misses 3 malignant tumours and wrongly flags 2 benign ones. The costlier error is the more common one.
Key line: bring Chapter 2 back in. In medicine a missed malignancy costs far more, so the threshold should move.
Next: the chapter in one idea.
Mental model
A supervised algorithm turns labelled examples into a decision rule.
The families differ only in the shape of rule they'll consider.
Ask what shape the real boundary is likely to take. That picks your first algorithm faster than any benchmark.
Notes · slide 21
Say: A supervised algorithm turns labelled examples into a decision rule. The families differ only in the shape of rule they'll consider.
Key line: ask what shape the real boundary is likely to take. That picks your first algorithm faster than any benchmark.
Next: check yourself.
Check yourself
- Training accuracy 99%, test accuracy 70%. Bias or variance?
- Why does KNN need feature scaling?
- What does the No Free Lunch theorem not say?
- Which model would you try first on 30 numeric clinical features, and why?
Notes · slide 22
Do: pairs, three minutes, then take answers.
Answers: 1. Variance: the model is overfitting. 2. Distances are dominated by the features with the biggest scales. 3. It doesn't say algorithms perform the same on real problems. 4. Logistic regression: a fast, calibrated, readable baseline that suits well-separated numeric features.
Lab: Bank Marketing has a leaky feature. Call duration is only known after the call. Some find it on the dataset page, some when the score jumps. Both are fine. Make sure nobody keeps it, and that every pair uses the same folds for all four models.
This week
- Read Chapter 10: The Data Science Lifecycle.
- Read Chapter 11: Supervised Learning: Overview of Approaches.
- Take the Chapter 10 quiz.
- Take the Chapter 11 quiz.
- Run the notebooks: Chapter 10 (opens in a new tab),Chapter 11 (opens in a new tab).
- Optional: the further reading for week 8.
Slide 1 of 23: The lifecycle, and choosing a supervised model
Keys: → or Space next · ← back · Home/End · F full screen · N notes. Swipe on touch screens. "Save as PDF" opens the print dialog with one slide per page: choose "Save as PDF" as the printer. "Print handout" adds the speaker notes, in black on white.