Readmission model: pick the honest metric
Scenario
You are a data scientist. Only 8 out of every 100 patients return to hospital. A model can look accurate by always guessing ‘no’. We need a fairer check.
Question
Keep some rows for testing, teach the model with the other rows, then count how many returning patients it found.
Your task
- Split the rows into a learning set and a test set
- Teach LogisticRegression using the learning set
- Show recall and the four confusion-matrix counts
Advanced · Data Filtering & Record Counting — question 1 of 30
1. Choose your dataset
Pick an industry and a size. Your code and results change to match.
Readmission model: pick the honest metric
Keep some rows for testing, teach the model with the other rows, then count how many returning patients it found.
Your code cell is below. Press Check my answer to run the cell — the result appears as Out [1].
💡 Explain my whole code, line by line (hover any word in the editor for a tip)
🌈 In short — no coding words
Altogether: this script runs top to bottom, one line at a time, building up the answer step by step.
Dataset & schema
discharges
The tiny starter data. Bigger data scrolls.
Fields
| age | length_of_stay | prior_admissions | readmitted_30d |
|---|---|---|---|
| 71 | 9 | 3 | 1 |
| 44 | 2 | 0 | 0 |
| 83 | 14 | 4 | 1 |
| 29 | 1 | 0 | 0 |
$ Press “Check my answer” — results appear here.Your next steps
Each item turns green when your answer includes it.
- Splits the data
- Fixes randomness
- Fits a model
- Reports recall
- Shows confusion matrix