learn-two-cultures-with-phoebe / Session 4 of 6
Learn The Two Cultures with Phoebe · Session 4 of 6

The two-cultures bench

Three sessions of argument, and now a count. The 569 real biopsies of the UCI Breast Cancer Wisconsin (Diagnostic) set sit inside this page, with the same fixed 171 held out that the session 1 build-along used. A logistic regression and a random forest are fitted in your browser, from scratch, every time you move a lever. Each culture gets two numbers: how many held-out biopsies it gets right, and how much of itself a person would have to read to explain it. Three levers change the models: how many features they may use, how big the forest is, and whether the training labels are real. A fourth changes the grader, and it is the one that lies.

🔴 Bench night Bring your session 1 seed range No code tonight, all clicking 45 min
0-3 · Welcome 3-14 · How to read the bench 14-40 · Six rungs, in order 40-45 · Q&A
Part 0

Where we start

A bench is a fixed set of rows and a fixed grader, so that when two models give two answers the only thing that differed was the model. Nothing on this bench is simulated. The biopsies are the real 1995 file, each value stored exactly; the split is the one seeded in session 1; both models are fitted by code you can read in the page source, and a separate Python reimplementation of the same algorithm reproduces every count to the biopsy.

🎫 Clear all three quiz questions to stamp your passport measured = counted from the 569 real rows ochre = data modelling · violet = algorithmic

★ What you walk out with tonight. The measured answer to "which culture wins on this data" at six settings, the habit of reading accuracy and explanation size together, the base rate as the line every score is read against, and two ways a bench can lie to you: one it catches, and one you have to refuse to click.

Part 1 · covers what the bench measures

Two numbers per culture, one line under both

6 min live

Breiman's culture is judged by accuracy on unseen rows. Box's and Cox's is judged by whether a person can read the model and learn something true from it. The bench prints both for both, so neither culture is graded only on the other's terms.

WHAT EVERY SETTING PRINTS both numbers for both cultures, and the line both must clear 569 real biopsies 398 fit 171 held out logistic regression accuracy on the 171 31 numbers random forest accuracy on the 171 1,647 questions THE GRADER counts right answers on the 171, once and the disagreements: which culture was right base rate 62.6% every biopsy "benign" Accuracy is Breiman's number. The count of things to read is the number Box and Cox would ask for. The bench prints both. Numbers shown are the default setting: all 30 features, 100 trees, real labels, graded on the held-out 171.
🔍 Click to zoom - the terracotta path is the grader's only input, and nothing upstream is allowed to touch it
LiveWhat each readout means4 min▶

Held-out accuracy. Right answers out of the 171 biopsies neither model saw while fitting. Each biopsy is 0.58 points, so read the count, not the decimal.

Numbers to read the whole model (ochre). One coefficient per feature plus an intercept. The bench lists the three largest, standardised so they are comparable, with their signs: a minus leans towards malignant, because benign is coded 1.

Yes or no questions inside it (violet). Every internal node in every tree is one question of the form "is worst area at or below this threshold?". The deepest path is how many questions one biopsy may have to answer. The bench also shuffles one feature at a time across the scored rows and counts the biopsies lost: Breiman's own importance idea from his hepatitis example, done on the held-out rows. Importance says which features matter, never in which direction.

Sign surprises (ochre, small print). How many coefficients point against their own feature's correlation with benign on the training rows. A readable model is only as honest as what it lets you read; session 2 explains where these come from.

Disagreements. The biopsies on which the two cultures give different answers, and which culture was right on each. Every other biopsy gets the same answer from both, so on this data the entire argument lives in these few rows.

Self-studyHow the two engines are built, and how they are checked4 min▶

The regression standardises each feature on the 398 fitting rows, then minimises the log loss plus half the squared size of the weights (scikit-learn's default C=1 objective, intercept not penalised) by Newton's method until the step is below 10-10. scikit-learn 1.9.0 gives the same held-out counts, with every coefficient within 0.000001 of the bench's.

The forest grows each tree on a bootstrap of the fitting rows drawn from a seeded generator, tries the square root of the number of features at every split (5 of 30, or 1 of 3), picks the split with the best Gini gain, and grows until every leaf is pure. The forest averages its trees' leaf shares and says benign above one half. A plain-Python copy of the same seeded algorithm reproduces every count on this page exactly.

The cross-engine tolerance. scikit-learn's own forest uses a different random stream, so it cannot match to the biopsy. Over its seeds 0 to 19 it scores 165 to 168 of 171 with all 30 features (median 167) and 165 to 169 with three (median 167). The bench's forest sits inside both ranges. Any forest-versus-regression gap smaller than that range is a gap between random draws, not between cultures.

Real world

The creators' own model had three features. The file's documentation, written by Wolberg, Street and Mangasarian in 1995, reports that the best predictive accuracy came from one separating plane in the space of just three features, worst area, worst smoothness and mean texture, with an estimated 97.5 percent from repeated ten-fold cross-validation, and that the classifier "has correctly diagnosed 176 consecutive new patients as of November 1995". That is their figure with their method; the bench's "creators' 3" lever lets both cultures try the same three features on our split.

Build-along · the bench

Six rungs, computed in front of you

★ 26 min · the main event

Work through the six settings in the table under the bench, in order. At each one, read the verdict line, then both columns top to bottom, then the disagreement line. Say out loud which number moved and which did not before moving on. The first four change the models. The fifth changes the grader. The sixth breaks the data on purpose.

RungSet the levers toWhat to watch
1All 30 · 100 · Held-out · RealThe default. The regression is ahead, and the whole gap is 3 biopsies
2The creators' 3 · 100 · Held-out · RealThe regression shrinks to 4 numbers; the forest grows; the lead changes hands
3All 30 · 1 tree · Held-out · RealA single tree: 19 questions, readable, and 12 biopsies behind
4All 30 · 10 · Held-out · RealTen trees already recover everything the hundred do
5All 30 · 100 · Training rows · RealThe peek: a perfect score that means nothing
6All 30 · 100 · Held-out · ShuffledThe break: both cultures fall towards the base rate

Read it in this order. Base rate, then the two accuracy counts, then the disagreement line, then the second numbers. It is tempting to read the two big percentages and stop. On this data the percentages differ by a few biopsies at every honest rung, and the second numbers differ by a factor of fifty.

Part 2 · covers what the four honest rungs find

The readable model wins, then it doesn't, and neither result is a verdict

7 min live

On all 30 features the logistic regression is right on 170 of the 171 held-out biopsies and the forest on 167. Restrict both to the three features the dataset's creators chose and the order flips: forest 168, regression 167. Breiman's Table 2 had forests halving tree errors; on this file, the data modelling culture holds its own.

HELD-OUT BIOPSIES CORRECT, OUT OF 171 axis starts at 100 · each unit is one biopsy · 7px per biopsy All 30, 100 trees 31 numbers · 1,647 questions The creators' 3, 100 trees 4 numbers · 2,700 questions All 30, one tree 31 numbers · 19 questions All 30, 10 trees 31 numbers · 152 questions 170 167 167 168 170 158 170 167 regression forest base rate 107 all 171 Every honest rung clears the base rate by 50 or more biopsies. The cultures differ by 1 to 3, except the lone tree.
🔍 Click to zoom - the flip at the second rung is one biopsy, inside the forest's own seed range of 165 to 169
RungRegression (ochre)Forest (violet)Disagree onSecond numbers
All 30, 100 trees170 of 171, 99.4%167, 97.7%3 (regression right on all 3)31 numbers vs 1,647 questions, depth 11
The creators' 3, 100 trees167, 97.7%168, 98.2%5 (regression 2, forest 3)4 numbers vs 2,700 questions, depth 13
All 30, 1 tree170, 99.4%158, 92.4%12 (regression right on all 12)31 numbers vs 19 questions, depth 8
All 30, 10 trees170, 99.4%167, 97.7%3 (regression 3)31 numbers vs 152 questions, depth 9
LiveWhy the readable model does so well here3 min▶

The creators' documentation says the two classes are linearly separable using all 30 features. A boundary that is close to a flat plane is exactly what a logistic regression draws, so on this file the data modelling culture's guess about the inside of the box happens to be nearly right. Breiman's argument was never that the equation is always wrong; it was that nobody checks. Here the check, 170 of 171 on unseen biopsies, is the credential.

Notice also what three features do to each culture. The regression becomes a model a clinician could hold in one hand: four numbers, with worst area carrying most of the weight (standardised coefficient -4.63), and no sign surprises. The forest, given fewer features to choose between, grows larger, 2,700 questions against 1,647, because each tree has to carve the same boundary out of fewer directions.

Self-studyThe lone tree, and Breiman's grades2 min▶

Set the forest to one tree. It asks 19 questions, never more than 8 on one biopsy, and you could draw it on a whiteboard, which is Breiman's "A+ on interpretability". It is also 12 biopsies behind the regression, every one of them a biopsy the regression gets right: "a B on prediction". Ten trees close almost all of that gap with 152 questions, and a hundred add nothing further. The step from a readable tree to an unreadable forest is where the Occam dilemma of session 1 lives, and on this data it is paid for in the first ten trees.

Real world

Hoadley's Fat Scorecard, in the same issue. Bruce Hoadley of Fair, Isaac reported fitting a plain logistic regression on credit data and finding that "all models fit with anywhere from 27 to 36 characteristics had the same performance on the test sample". His 27-characteristic scorecard slightly outperformed a neural network with 2,000 connection weights. He called it an excellent algorithmic model made from a simple data modelling tool. The bench's first rung is the same shape of result on a different domain.

Part 3 · covers the peek and the break

Two ways a bench can lie, and how this one tells you

5 min live

A bench earns trust by being able to report a worse number. Rung 6 proves this one can: shuffle the training labels so no real signal is left, and both cultures fall from the high nineties towards the base rate. Rung 5 shows the opposite failure, a number that looks better than anything honest, produced by grading a model on the rows it memorised.

THE BREAK · labels shuffled THE PEEK · graded on training rows 170 167 116 114 base rate 107 both land within 9 biopsies of it 1,647 6,730 questions: the forest grows 4 times bigger fitting noise 398 fitting rows graded on them forest 398 of 398 100.0%, memorised regression 392 98.5%, below its held-out 99.4% the held-out 171 can flatter as well as punish The break proves the bench measures signal. The peek proves a grader that has seen the rows measures memory.
🔍 Click to zoom - the red panel is the only setting whose top number is higher than any honest one, and it is the one to distrust
LiveWhy the break does not reach exactly 62.6 percent2 min▶

With the labels shuffled, there is nothing true left to learn, so a model's best move is to call most biopsies benign. The regression lands on 116 of 171 and the forest on 114, against the do-nothing 107. The residue is what one particular shuffle leaves behind by chance: the bench uses one fixed permutation so every visitor sees the same numbers, and a different permutation would give a slightly different residue. The honest reading is the size of the fall, 54 and 53 biopsies, not the exact landing point. The forest, meanwhile, grows 6,730 questions deep into nothing, four times its honest size: a complex model will always find something to fit.

Self-studyThe peek in real projects2 min▶

Nobody sets a switch that says "grade on the training rows". The peek arrives by degrees: tuning a setting until the test score improves, choosing among ten candidate models by their test score, re-splitting after a disappointing result. Hoadley names it in his comment on Breiman, "in industry and academia, there is sometimes a little tinkering, which involves peeking at the test sample. The result is some bias in the test sample or cross-validation results", and asks the question that has no easy answer: "How do you optimize your results and get an unbiased estimate of the generalization error?" Session 3 is about the discipline that answers it; session 5 is about the institution, the common task framework, that enforces it.

Homework

Before session 5

30 min
  1. Fill the six-rung table from the bench yourself: both counts, the disagreement split and both second numbers. Circle the rung you would defend to a clinician, and the one you would defend to a data science lead.
  2. Compare with your session 1 seed range. Is the forest's score at rung 1 inside the 20-seed range you recorded? What does that say about the 3-biopsy gap?
  3. Write the peek in your own project. Name one decision in your last model build that used the test set before the final grade. Say what an untouched set would have cost you.
  4. Read Donoho's section 6 on the common task framework before session 5. Mark the three ingredients.
Check yourself

Three questions

Clear all three and session 4 gets stamped in your passport.

1 · With the creators' 3 features the forest gets 168 of 171 and the regression 167. What is the honest conclusion?

A one-biopsy lead inside the forest's own seed-to-seed range is noise between random draws, not a difference between cultures. The creators' figure used a different method and repeated cross-validation, so it is not comparable to one fixed split.

2 · Why does the break button make the bench more trustworthy rather than less?

The break is a placebo. If scores stayed high with the labels shuffled, the bench would be measuring a leak or a bug. The residue above 107 is one fixed shuffle's chance pattern, and the page says so rather than hiding it.

3 · Graded on the training rows, the forest scores 398 of 398. Graded on the held-out rows, 167 of 171. Which number goes in the report?

Both are real counts; only one answers the question. The regression shows the subtler lesson in the same rung: its held-out 99.4 percent is higher than its training 98.5 percent, because 171 rows is small and can flatter a model as easily as punish it.

Sources covered

What this session teaches, and where it came from

✓Every count, percentage and size on the benchComputed in the browser from the 569 real rows of UCI Breast Cancer Wisconsin (Diagnostic), doi 10.24432/C5DW2B, CC BY 4.0; reproduced exactly by an independent Python run of the same seeded algorithm before any page quoted it
✓The regression, cross-checked against scikit-learn 1.9.0Same held-out counts, coefficients within 0.000001
◐The forest, against scikit-learn's forestDifferent random stream, so a stated tolerance instead of a match: 165 to 168 of 171 (all 30) and 165 to 169 (the creators' 3) over seeds 0 to 19
✓The creators' three features and their 97.5 percentQuoted from the dataset's documentation (wdbc.names, 1995); their method, not reproduced here
✓Hoadley's Fat Scorecard and the tuning dilemmaStatistical Science 16(3), comment on Breiman, read at source
◐Any general verdict between the culturesNot claimed. One file of 569 biopsies, nearly linearly separable; other data would order the rungs differently

Every fact on this page, and its verification tier, is recorded in the course's source map.

Session 4 cheat sheet · pin this

Two numbers per cultureHeld-out accuracy, and how much you must read to explain it: 31 numbers or 1,647 questions.
Base rate first107 of 171, 62.6 percent, for calling everything benign. Every score is read against it.
Count the disagreementsAt rung 1 the cultures differ on 3 biopsies. That is the whole argument, on this data.
Gap smaller than seed noiseThe forest's own seeds span 165 to 169. A one-biopsy lead is a tie.
The breakShuffle the labels: 170 to 116, 167 to 114. A bench must be able to fall.
The peek398 of 398 on training rows is memory. Only the untouched 171 measures prediction.