P6: A model you can defend

The board shows rows being written into a store and read back. A model for a table starts from the same thing: rows, each one a record, and the care you take over which rows are used for what.
In June 2021 a team at Michigan Medicine, led by Andrew Wong, published a test of a widely used sepsis warning model. Sepsis is a dangerous reaction of the body to an infection, and an early warning can save a life. The team checked the model on 27,697 patients and 38,455 hospital stays between December 2018 and October 2019. The score that measures how well a model separates sick from not sick (called AUC, where 0.5 is a coin toss and 1.0 is perfect) came out at 0.63. The vendor had reported a higher range, 0.76 to 0.83. The lesson is not that the model was useless. It is that a score reported by the builder is not the same as a score measured by someone else on their own patients.
You are about to put a model in your portfolio. A hiring engineer will ask one question of it: “how do you know it works?” By the end of this lesson you will be able to build a small model on a table of rows, score it honestly, catch two kinds of leakage, and write the one page that lets a stranger trust your number.
The history (optional)
The Michigan study is Wong et al., “External Validation of a Widely Implemented Proprietary Sepsis Prediction Model in Hospitalized Patients”, JAMA Internal Medicine, published online 21 June 2021. Epic, the vendor, disputed how the study defined sepsis. The study’s conclusion was that the model had poor discrimination and calibration. A one-page report that states what a model was trained on and where it fails, called a model card, was proposed by Margaret Mitchell and colleagues in 2019.
Before you start. You need Honest scores: cross-validation, leakage and bias-variance, which gave you the training, validation and test piles, cross-validation and the idea of leakage. You need Trees, forests and boosting, where a decision tree asked yes-or-no questions about columns, and Precision and Recall (where to set the spam filter's bar), which gave precision (of the ones the model flagged, how many were right) and recall (of the real cases, how many the model found). You need A repo a stranger can judge in two minutes, which says what a good project folder contains. This lesson fills the model part of that folder.