← Back to projects
Heart Disease Risk Screening logo
XGBoost · FastAPI

Heart Disease Risk Screening

Imbalance-aware heart-risk screening with XGBoost, PR-AUC tuning and recall-focused thresholds.

XGBoostFastAPIMLOps

Overview

A machine-learning risk-screening project built from BRFSS survey data, designed to identify patterns associated with heart-disease risk rather than provide medical diagnoses. The pipeline uses XGBoost and explicitly addresses class imbalance, placing particular emphasis on recall, precision-recall performance, and careful threshold selection. It incorporates leakage-aware resampling, cross-validation, training and test separation, and a FastAPI service for returning screening risk scores. The project highlights responsible evaluation in a high-stakes domain, where predicting a rare positive class requires more than optimizing overall accuracy.

Technical details

The code benchmarks Logistic Regression, Random Forest, and XGBoost under original, randomly oversampled, and undersampled class distributions. It keeps resampling inside imbalanced-learn pipelines to avoid leaking synthetic/repeated cases across validation folds. XGBoost candidates are tuned by average precision (PR-AUC), using stratified cross-validation, then probability thresholds are selected on validation data for recall-focused F2/F3/F4/F5 trade-offs before final test evaluation. The production training configuration uses five CV folds and up to 12 randomized parameter candidates per selected sampling strategy.