HALF THE FILE SITS EXACTLY AT THE FORM'S CEILING. 48.6% of 101,766 encounters record exactly 9 diagnoses, and only 115 in the entire file — 0.113% — record more. A count of a patient's actual conditions would taper. A count bounded by a claim form with 9 diagnosis fields piles up against the bound, and that is what this does. The target is a property of the paperwork.
The number of diagnoses is a field on a billing form, not a fact about a patient
On 101,766 hospital encounters, what does a model predicting the number of recorded diagnoses actually learn?
What the analysis found, including the results that went against us
Each of these came out of the run. None has been softened.
Where the target piles up
Number of encounters at each recorded diagnosis count. The distribution rises to a spike at nine and collapses immediately after, because the claim form has nine diagnosis fields.
run.py section 1.
THE LEAKAGE EVERYONE WARNS ABOUT IS NOT HERE, AND WE EXPECTED IT TO BE. 16,773 of 71,518 patients have more than one encounter, and 8,965 of them straddle a random split — the textbook setup for an inflated score. It does not inflate: R-squared is 0.324 on a random split and 0.333 when no patient may appear on both sides, a difference of -0.009 in the wrong direction. This project was written expecting the opposite and reports what it found. Repeat patients leak when the target is a stable property of the person; this target is a property of the visit's paperwork, so knowing the patient does not help.
What the model is learning from
Variance explained using only clinical features, only administrative ones, and all of them, all on a patient-grouped split. The administrative block does most of the work.
run.py section 3.
ADMINISTRATIVE AND CLINICAL FEATURES PREDICT IT ABOUT EQUALLY WELL, WHICH IS ITS OWN ANSWER. Administrative fields alone — admission type, discharge disposition, admitting source, specialty, payer, length of stay — reach an R-squared of 0.246. Clinical fields alone — lab procedures, medications, A1C, glucose, age — reach 0.225, a difference of +0.022. Neither block dominates, and together they reach only 0.333. A target that paperwork predicts as well as pathology does is not measuring pathology.
THE SPECIALTY FIELD IS MISSING FOR 49.1% OF ENCOUNTERS AND ITS ABSENCE IS INFORMATIVE. Encounters that record an admitting specialty carry 7.11 diagnoses on average; those that do not carry 7.75, a gap of -0.64. The missingness is not random — it tracks how an encounter was documented — so imputing it would erase a real signal, and using it lets the model key on documentation practice. Payer code is missing for 39.6%.
WHAT THIS DATA CAN SUPPORT IS A STATEMENT ABOUT CODING, NOT ABOUT ILLNESS. Every finding above is reproducible and none of them is clinical. The file is a good dataset for studying how administrative data behaves and a poor one for studying patients, and the distinction is invisible if you take the column name at face value. That is the general lesson: a target is what a field records, not what its name suggests.
Full results tables
The same model, two splits
| Split | R-squared |
|---|---|
| Random over encounters (the usual choice) | 0.324 |
| Grouped so a patient stays on one side | 0.333 |
Where the target actually comes from
| Diagnoses recorded | Encounters | Share |
|---|---|---|
| 1 | 219 | 0.2% |
| 2 | 1,023 | 1.0% |
| 3 | 2,835 | 2.8% |
| 4 | 5,537 | 5.4% |
| 5 | 11,393 | 11.2% |
| 6 | 10,161 | 10.0% |
| 7 | 10,393 | 10.2% |
| 8 | 10,616 | 10.4% |
| 9 | 49,474 | 48.6% |
Limitations
Stated by the analysis, not added afterwards. A project without these is not finished.
- NOT A CLINICAL STUDY. Nothing here was validated for clinical use, no number should inform any decision about any patient, and no clinician reviewed it. The subject is a prediction target and how it behaves, not medicine.
- The nine-slot claim form is the documented explanation for the ceiling and it fits the distribution exactly, but the file does not record which form each encounter used. The spike at nine and the near-absence above it are measured; the mechanism is inferred from the era's standard billing form.
- The data covers 1999 to 2008 across 130 US hospitals, pre-dating the electronic health record mandate, the readmission penalty and ICD-10. Coding practice has changed since, so nothing here describes how a hospital documents encounters now.
- The administrative and clinical feature blocks are a judgement about which column belongs where, and two of them could be argued either way — length of stay reflects both how sick someone is and how a hospital operates. Moving it between blocks shifts the split of explained variance without changing the direction of the result.
- Encounters are the unit throughout except where stated. A patient with several admissions contributes several rows, and while the grouped split stops that inflating the score, it still means frequently-admitted patients carry more weight in what the model learns.
Data: UCI Diabetes 130-US Hospitals for Years 1999-2008, CC BY 4.0. 101,766 rows, 1999 to 2008.
Libraries and methods this analysis used
Read from this project's own run.py when the page was built — 279 lines of it. Not a list of everything we know; a list of what this analysis imports and calls.
5 names from pandas appear in this analysis.
- Categorical
- fillna
- read_csv
- reindex
- value_counts
4 names from scikit-learn appear in this analysis.
- GroupShuffleSplit
- HistGradientBoostingRegressor
- r2_score
- train_test_split
1 names from NumPy appear in this analysis.
- errstate
How every number on this page is checked
A script deletes each result file, re-runs the project and diffs the output. If a headline figure moves, the check fails, and the page does not ship. That is the only reason to believe anything on this page.
Running this method on your own data
The method above transfers; the result will not. Send us a extract and we will tell you what is forecastable in it and what is not, before anyone signs anything.