Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Predicting Medicare Hospitalizations: Optimizing for Clinical Alert Fatigue

📖 Project Overview

Predictive modeling in healthcare frequently struggles with high false-positive rates, leading to "alert fatigue" among care management teams. This project builds an end-to-end machine learning pipeline to predict 2010 inpatient hospitalizations using administrative claims data from the previous two years (2008-2009).

Rather than stopping at raw predictive power, this project emphasizes clinical resource allocation. By engineering a custom Charlson Comorbidity Index (CCI) and optimizing the decision threshold of an XGBoost classifier, the model demonstrates how to actively balance true positive capture rates against the operational burden of false alarms.

💾 Data Source

This project utilizes the CMS DE-SynPUF (Data Entrepreneurs Synthetic Public Use File) dataset (2008–2010). It integrates multiple highly fragmented claims tables:

  • Beneficiary Summaries (Demographics & Chronic Conditions)
  • Inpatient & Outpatient Claims
  • Carrier Claims (Lines A & B)

🛠 Project Architecture & ETL

Administrative claims data is complex and hierarchical. A custom ETL pipeline was developed to parse gigabytes of raw CMS CSVs into a relational SQLite database.

Directory Structure

├── notebooks/
│   ├── 01_setup_db.ipynb                 # ETL: CSVs to SQLite
│   ├── 02_feature_engineering.ipynb      # Clinical mapping & feature extraction
│   └── 03_modeling_xgboost.ipynb         # XGBoost training, tuning, & SHAP evaluation
├── src/
│   ├── config.py                     # Environment & path management
│   ├── etl.py                        # Database schema & population scripts
│   ├── features.py                   # SQL queries for utilization & temporal extraction
│   └── mappings.py                   # Custom ICD-9 regex dictionaries for CCI
├── models/                           # Serialized XGBoost JSON & target encoders
├── outputs/plots/                    # SHAP and evaluation visualizations
├── requirements.txt                  # Environment dependencies
└── .gitignore

Feature Engineering

The feature matrix was constructed to capture both clinical severity and social determinants of health:

  • Custom Charlson Comorbidity Index (CCI): Vectorized regex mappings extracted 17 distinct chronic condition flags directly from historical ICD-9 billing codes.
  • Geographic Target Encoding: Applied smoothed target encoding to high-cardinality geographic data (State + County IDs), successfully capturing localized risk variations.
  • Utilization Aggregation: Consolidated 13-line carrier claims, outpatient visits, and inpatient histories into unified financial and encounter metrics.

Feature Matrix Preview

The final gold-layer dataset contains 22,908 patients.

age is_male county_risk_encoded total_claims_2009 cci_score Diabetes_Comp target
76 1 0.087 99 11 1 1
82 0 0.112 14 2 0 0
68 1 0.145 42 5 1 1

Modeling & Clinical Resource Allocation

The predictive engine is an XGBoost Classifier optimized via RandomizedSearchCV for maximum Area Under the Curve (AUC). To address the extreme class imbalance (~10% hospitalization prevalence), scale_pos_weight was dynamically calculated.

Optimizing for Clinical Workload: In population health management, intervention capacity is the primary constraint.

  • F1-Score Maximization: The decision threshold was shifted from the default (0.50) to 0.56, balancing the trade-off between missing high-risk patients and overwhelming staff with false alarms.
  • Cumulative Gains (Lift): The optimal threshold flags 34% of patients and captures 57% of future hospitalizations. Meanwhile, if a hospital only has the capacity to intervene on 20% of their population, random outreach catches 20% of future admissions. Using this model to target that same 20% captures nearly 36% of all future hospitalizations.

Model Optimization and Cumulative Gains

Model Interpretability (SHAP)

Black-box models are unacceptable in clinical informatics. SHAP (SHapley Additive exPlanations) was used to extract both global feature drivers and local, patient-level decision logic.

Global Drivers

Prior utilization (total_claims_2009) is the dominant predictor of future admission. However, the county_risk_encoded feature reveals a massive geographic disparity in baseline health outcomes.

Feature Importance Summary

Local Patient Explainability

Below is the breakdown for a single high-risk patient. Despite severe clinical markers (99 claims, CCI of 11), their geographic location acts as a massive protective buffer, demonstrating the model's ability to balance clinical and social determinants.

Local Patient Waterfall

How to Run

  1. Clone the repository and install dependencies:
    pip install -r requirements.txt
  2. Download the raw Sample 1 DE-SynPUF CSV files and place them in the data/raw/ directory.
  3. Run the notebooks in sequential order (01 -> 02 -> 03) to build the database, extract the feature matrix, and train the model.

Tech Stack

  • Language: Python 3.10+
  • Data Processing: Pandas, PyArrow, SQLite3
  • Machine Learning: XGBoost, Scikit-Learn, Category Encoders
  • Interpretability: SHAP, Matplotlib, Seaborn

About

This project builds an end-to-end machine learning pipeline to predict 2010 inpatient hospitalizations using administrative claims data from the previous two years (2008-2009). Implements XGBoost classifier and utilizes data from the CMS DE-SynPUF dataset (2008–2010).

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages