Datasets:
|
Download DATA_REMEDIATION_LOG.md from drdavidprivacy/carepivot-data: direct link, hf CLI and curl.
- Browser
- Download file 19.7 kB
-
https://huggingface.co/datasets/drdavidprivacy/carepivot-data/resolve/main/DATA_REMEDIATION_LOG.md
- Command line
-
hf download hf://datasets/drdavidprivacy/carepivot-data/DATA_REMEDIATION_LOG.md
-
curl -L -o DATA_REMEDIATION_LOG.md https://huggingface.co/datasets/drdavidprivacy/carepivot-data/resolve/main/DATA_REMEDIATION_LOG.md
19.7 kB
| # CarePivot working file: data remediation log (Week 3) | |
| ALDERWYN HEALTH: CLINICAL INFORMATICS TEAM | |
| CAREPIVOT ENCOUNTER EXTRACT: DATA REMEDIATION LOG | |
| *Prepared by the clinical informatics team for the CarePivot program file, in response to the Week 2 review. One row per change the team has now made to the extract before the first model is trained, and one row per finding the team chose to document rather than change. Two terms are used the same way in every row. The working file is every column the team holds after remediation: the fields as loaded, the fields added beside them, and the outcome. The model inputs are the subset of those columns the model will be trained on. A field can be in the working file and not a model input. Three rules apply to every row. The raw field is never overwritten. A field held out of the model inputs stays in the working file for measurement: the team takes the label off the patient, not the patient out of the file. And rows leave only under a written rule a reader could re-run, which happens twice in this log and nowhere else.* | |
| **Extract:** 101,766 rows and 50 columns as loaded (47 fields, two identifiers, and the outcome as recorded), plus the working outcome built in section 3. 99,340 rows and 58 columns in the working file after remediation (2,426 rows removed under two written rules, 7 columns added beside their sources). Those 58 columns are 42 model inputs, 15 fields held out of the inputs, and the outcome column. Outcome: readmitted_within_30_days, value of interest "yes," 11.2 percent of 101,766 as loaded and 11.4 percent of 99,340 after the removals. Both rates are floors, because the label is readmission per the system's record. | |
| | Row | Field or fields | What the Week 2 review found | Operation performed | Reason | Options considered and not taken | Before and after | Where it lands | Notebook | | |
| |---|---|---|---|---|---|---|---|---| | |
| | R-1 | readmitted, readmitted_within_30_days | The outcome is recorded three ways (NO 54,864, >30 35,545, <30 11,357). NO means no readmission on record, the file has no date field, and the review asked when the window closed and how many NO encounters were discharged within thirty days of it, and what a readmission outside the system records | Define the label window, and leave the label as is and document. The label is "readmitted within thirty days per the system's record." Censoring at the window's end and out-of-system readmissions are recorded as limitations | Documentation: NO means no readmission in the system's own record. Open: the close date, because the documentation gives a ten-year span and no date per encounter, so the censored count cannot be computed. Open: readmissions elsewhere, which the record cannot see. The 11.2 percent is a floor, and every evaluation rate inherits the caveat. The three-way field is the label's own ingredient and is never an input | Redefine the label as any readmission on record (46.1 percent), which would change the program's question. Trim a censored tail the file cannot identify | No change to the data. Rate of "yes" 11.2 percent, 11,357 of 101,766 as loaded. readmitted (three values) stays beside the working outcome | readmitted: in the working file, not a model input. readmitted_within_30_days: the outcome column. The window and the out-of-system limitation: recorded for the datasheet and the evaluation stage | 11.1 | | |
| | R-2 | number_inpatient, encounter_id (as an ordering) | A patient's first stay in the file is readmitted at 8.8 percent and a later stay at 16.7 percent, with "first" taken as the lowest encounter_id. Nothing in the documentation certifies the identifiers are assigned in time order | Exclude a leakage feature, and leave as is and document. No first-versus-later flag is derived, and total stays per patient is never derived. number_inpatient, the documented prior-year count, is the only history feature | An uncertified order would put an unverifiable feature in the model. A total-stays count includes stays after the one being scored, which is information from the future. number_inpatient carries the history the system knows at the discharge door, and the documentation defines it | Derive "first stay in file" as a feature (the order is open). Derive total stays per patient (leakage). Certify the order by assumption | No change to the data. number_inpatient: 67,630 encounters at 0 (8.4 percent readmitted), 19,521 at 1 (12.9), 7,566 at 2 (17.4), 7,049 at 3 or more (25.7). Association with the outcome 0.149, unchanged | number_inpatient: model input, unchanged. The identifier order: an open item in the datasheet. No field added | 11.2 | | |
| | R-3 | time_in_hospital, num_lab_procedures, num_medications (the inclusion rules) | Length of stay stops at exactly 14 days, and the review asked what rules produced the extract | Leave as is and document. The five documented inclusion rules are recorded: an inpatient encounter, a diabetes diagnosis entered, a stay of 1 to 14 days, laboratory tests performed, medications administered | Documentation answers the question. Every rate in the file is a rate among stays that met these rules, and the patients whose stays fell outside them, the longest stays above all, are patients the model never learned about and will still be asked to score | Treat the 14-day cap as a recording ceiling to smooth. Drop the rule from the record because it cannot be changed | No change to the data. The file shows three of the five rules: time_in_hospital 1 to 14, num_lab_procedures minimum 1, num_medications minimum 1. The first two rules cannot be re-run from the extract's three diagnosis fields (number_diagnoses runs up to 16). How many encounters fell outside the rules is not documented | Not a field. The rules are recorded for the datasheet's description of who is in the file | 11.3 | | |
| | R-4 | discharge_disposition_id | The strongest category field: code 22 (rehabilitation facility) 27.7 percent readmitted on 1,993 encounters against code 1 (home) 9.3 percent on 60,234. The review asked whether the code is known at the moment CarePivot would score | Leave as is and document, and record a rule for the modeling stage: two model variants, with and without the discharge disposition among the inputs | The code table defines every code and says nothing about the workflow. Nobody has confirmed that the code is final when the score is computed. A field the system does not hold at scoring time is leakage however strong it looks, and a field it does hold is the best signal in the file. Neither is settled by fiat this week | Keep it as an input on the assumption it is known (unconfirmed). Exclude it on the assumption it is not (throws away the strongest field on a guess) | No change to the data. The field stays a candidate input and is grouped into families in R-10 | Raw code: in the working file, not a model input (R-10). Family copy: model input. The timing question: an open item, and the two-variant rule is recorded for the modeling stage | 11.4 | | |
| | R-5 | race | Race is unrecorded ("?") in 2,273 encounters belonging to 1,977 patients, readmitted at 8.3 percent, the lowest rate in the field. Only 144 of those rows belong to a patient whose race is recorded in another stay, and 123 patients carry more than one race value across their stays | Hold protected attributes out of the inputs, keep them for measurement. "?" is kept as its own level. Nothing is imputed | Race is a protected characteristic under Section 1557, and the Chief AI Officer's watch list measures error rates by recorded race with the unrecorded group as a row of its own. You cannot measure what you deleted. Filling race from another stay assigns a value the chart does not carry, and 123 conflicts show the field is unstable within a person. The team takes the label off the patient, not the patient out of the file: every encounter stays in the training data with all of its other fields, and the model is never told the patient's race. Gender and age stay inputs, as clinical variables recorded for every stay, and stay measurement lenses too | Impute race from another stay (144 rows) or from other fields. Delete race from the file. Drop the 2,273 unrecorded rows. Hold gender and age out as well (not taken: both are clinical variables the documentation records for every stay, and watch-list item five tests age by band) | 47 candidate inputs, then 46. Race still in the working file with six levels including "?". Rows 101,766 before and after | In the working file, not a model input. "?" reported as its own group at the evaluation stage. Every row stays | 11.5 | | |
| | R-6 | medical_specialty, payer_code | Both fields were absent from the dictionary. medical_specialty has 73 levels and is unrecorded in 49,949 encounters (49.08 percent). payer_code is unrecorded in 40,256 (39.6 percent) and carries codes with no key | Merge rare levels into documented families for specialty: a new field medical_specialty_family, eleven families by name, with "?" as its own level, "not recorded," beside the raw field. Drop payer_code from the inputs, keep it in the working file as a fairness lens | Documentation, now corrected: medical_specialty is the admitting physician's specialty, payer_code the primary payer as a two-letter code, examples only, no key. Seventy-three levels with half missing is noise unless grouped, and the mapping is printed in full. A payer is a proxy for access to care, the mechanism the watch list tests, and belongs in the measurement, not the model. The key remains open | Keep 73 specialty levels as an input. Treat "?" as missing and impute. Keep payer_code as an input. Assign meanings to the payer codes (no key exists) | Specialty 73 levels, then 11: not recorded 49,949, general medicine 22,171, surgery and surgical specialties 8,695, emergency and trauma 7,565, cardiology 5,359, other medical subspecialties 2,466, other or unclassified 1,646, nephrology 1,613, psychiatry and psychology 963, obstetrics and gynecology 774, pediatrics 565. payer_code: 18 values, unchanged. 46 candidate inputs, then 45 | medical_specialty: raw in the working file, the family copy is the model input. payer_code: in the working file, not a model input | 11.6 | | |
| | R-7 | diag_1, diag_2, diag_3 | The three diagnosis fields hold 717, 749, and 790 distinct codes, and the review asked what standard they follow and whether they carry the type of diabetes | Merge rare levels into documented families: three new fields, diag_1_chapter, diag_2_chapter, diag_3_chapter, each placing the code in one of the nine documented ICD-9-CM chapters (circulatory, respiratory, digestive, diabetes, injury, musculoskeletal, genitourinary, neoplasms, other), beside the raw codes | Documentation: the codes are ICD-9-CM (International Classification of Diseases, Ninth Revision, Clinical Modification), read at the three-digit level, and the documented approach uses nine chapters by code range. Seven hundred levels cannot be explained to anyone, and nine documented chapters can. The type of diabetes sits in the decimal of a 250 code and is not derived as a field, because the raw codes keep it available | Keep the raw codes as inputs (700 levels each). Derive the type of diabetes as a field. Drop the diagnosis fields | Each field 700-plus levels, then 9. The unrecorded value ("?") lands in "other" as the documented approach places it: 21, 358, and 1,423 codes. Primary diagnosis: circulatory 30,437, other 18,193, respiratory 14,423, digestive 9,475, diabetes 8,757 (13.0 percent readmitted), injury 6,974, genitourinary 5,117, musculoskeletal 4,957, neoplasms 3,433 | Raw codes: in the working file, not model inputs. Chapter copies: model inputs | 11.7 | | |
| | R-8 | discharge_disposition_id (rows) | 2,423 encounters carry a discharge code meaning death or hospice, 1,652 of them a code meaning the patient died. All but 43 are "no" under the working outcome, and the 1,652 can never be anything else | Drop rows under a stated rule: discharge_disposition_id in 11, 13, 14, 19, 20, 21. The first of two row removals in the log | Documentation: the published analysis removed encounters that ended in death or hospice before modeling. A record that cannot carry the outcome teaches the model that the sickest discharges never return. The rule is written, and a reader can re-run it. The outcome is re-aligned to the working file after the removal. Watch-list item six keeps the test of whether removing them shifts who lands in the top 15 percent | Keep them and test at the evaluation stage only. Remove the deaths and keep the hospice discharges (a hospice discharge is scored for a program that cannot enroll it) | Rows 101,766 before, 99,343 after, 2,423 removed (11 expired 1,642, 13 hospice at home 399, 14 hospice in a medical facility 372, 19 eight, 20 two, 21 none). Rate of "yes" 11.2 percent before (11,357), 11.4 percent after (11,314 of 99,343). Distinct patients 71,518, then 69,990 | Rows leave under this rule and no other in this row. No column changes | 11.8 | | |
| | R-9 | weight, max_glu_serum, A1Cresult | weight is unrecorded in 96.9 percent of encounters. The two lab fields hold "None" in 94.7 and 83.3 percent of encounters as loaded, and the dictionary says None means the test was not performed | Drop weight from the inputs, keep it in the working file. Treat "None" as a category, not as missing, in both lab fields. Leave as is and document | Documentation: weight is mostly unrecorded, and None means not ordered. Weight is not a field: after the R-8 removal it is unrecorded in 96,218 of 99,343 encounters, and only 36 of those rows belong to a patient with a weight band recorded in another stay, so there is nothing to fill from. "Not ordered" carries a rate of its own and is information about the care received, which is why watch-list item four tests it as a feature | Impute weight from another stay (36 rows) or from a population value. Delete weight from the file. Treat None as missing and impute a result | weight: 45 candidate inputs, then 44, still in the working file. Lab fields: no change. After R-8, max_glu_serum None 94,191 (11.3 percent readmitted), A1Cresult None 82,509 (11.7 percent) against 9.8 to 10.1 for any result | weight: in the working file, not a model input. max_glu_serum and A1Cresult: model inputs, unchanged, with None as a documented level | 11.9 | | |
| | R-10 | admission_type_id, discharge_disposition_id, admission_source_id | Each code table names codes meaning NULL, Not Available, Not Mapped, or Unknown/Invalid, and the review asked what each records. Code 1 means a different thing in each field | Recode undocumented values into a named level, and merge levels into documented families: three new fields beside the raw codes. admission_type_group keeps the documented levels with the unknown family (5, 6, 8) merged into "unknown." discharge_disposition_family groups the codes into the Code Table Companion's families: home, facility transfer, death or hospice, still a patient or expected to return, unknown (18, 25, 26). admission_source_family: referral, transfer from another facility, emergency room, birth-related, court or law enforcement, unknown (9, 15, 17, 20, 21) | Documentation: the code table names the unknown codes and does not say how they differ, so the team has not guessed at a difference. The families are the Companion's definitions, not findings from the data, and every code in every family is printed. Raw codes are kept so that any grouping can be undone | Keep every code as its own level. Treat the unknown family as missing and impute. Drop the rows carrying an unknown code | admission type 8 codes, then 6 levels (unknown 10,144, 10.2 percent of rows). Discharge disposition 21 codes present after R-8, then 4 levels (home 73,867, facility transfer 20,772, unknown 4,680, still a patient 24, death or hospice 0). Admission source 17 codes, then 6 levels (unknown 6,854, 6.9 percent). Levels under 30 records (newborn 10, trauma center 18, court or law enforcement 15, birth-related 5, still a patient 24) are kept as the Companion defines them and documented as anecdotes | Raw codes: in the working file, not model inputs. The three family copies: model inputs | 11.10 | | |
| | R-11 | gender (rows), examide, citoglipton | gender is Unknown/Invalid in 3 encounters. Two of the 23 medication fields, examide and citoglipton, take one value, "No," in every row | Drop rows under a stated rule: gender is Unknown/Invalid. The second and last row removal in the log. Drop the two constant fields from the inputs, keep them in the working file | Three rows cannot be evaluated as a group or reported on, and would sit in the model as a level with almost nothing in it. A field with one value carries nothing. The outcome is re-aligned to the working file after the removal | Keep the three rows as a third gender level. Recode them into the larger group (assigns a sex the chart does not carry). Delete the two constant fields from the working file | Rows 99,343 before, 99,340 after, 3 removed. Rate of "yes" 11.4 percent after (11,314 of 99,340). Rows removed across the whole log, under two rules: 2,426 of 101,766. Candidate inputs 44, then 42 | The three rows leave under this rule. examide and citoglipton: in the working file, not model inputs | 11.11 | | |
| | R-12 | patient_nbr, encounter_id (the train/test split) | 101,766 encounters belong to 71,518 patients, and a patient's later stays are readmitted nearly twice as often as a first stay. The published analysis kept only each patient's first encounter | Fix the train/test split: by patient (a group split on patient_nbr), stratified where possible, 80 percent of patients for training and 20 percent held back as the test set, fixed seed. Recorded now, executed at the modeling stage. Every stay is kept. The two identifiers are never model inputs | Keeping every stay preserves the repeat patients the program exists for. A row split would let the same person sit on both sides and flatter the model. The patient split removes the leakage that the published approach avoided by deletion. Watch-list item one compares it against a row split with the gap reported. The held-back test set is never used for training | Keep each patient's first encounter only (deletes 30,248 later stays, and "first" is open). Split at random by row. Split by time (no date field) | Not executed. Working file 69,987 patients and 99,340 encounters, 8,805 patients (12.6 percent) with at least one "yes" stay. Expected: 55,990 training patients and 13,997 in the held-back set, about 79,472 and 19,868 encounters (about 9,051 and 2,263 "yes"). Smallest measurement groups in the held-back set: race "?" about 446 of 2,232, Asian about 126 of 628, age [0-10) about 32 of 160, [10-20) about 138 of 690 | Not a field. A rule recorded for the modeling stage. encounter_id and patient_nbr: in the working file, never model inputs | 11.12 | | |
| **Open items carried in the datasheet, not resolved by any row above:** the date the extract's window closed and the censored tail, readmissions outside the system, whether encounter identifiers are assigned in time order, whether the discharge disposition is final at scoring time, why 123 patients carry more than one race value and who the 1,977 patients with no recorded race are, and the key to the payer codes. Section 12 of the notebook prints the same six. Two decisions are recorded for the modeling stage and not made here: the two discharge-disposition variants (R-4) and the class weighting decision, since about one encounter in nine carries the outcome. | |
| *End of log. Questions about any row go to the clinical informatics team through the AI Governance Office.* | |