Instructions to use kiselyovd/cardio-risk-rf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use kiselyovd/cardio-risk-rf with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("kiselyovd/cardio-risk-rf", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
cardio-risk-rf
Production-grade tabular cardiovascular-disease classifier on the sulianova Cardiovascular Disease Dataset (70 000 patients, 11 clinical features, balanced 50/50 target cardio). The main artefact is cardio_risk_lgbm.joblib (LightGBM, Optuna-tuned, native NaN handling); the baseline is cardio_risk_rf.joblib (RandomForest with median imputation). Both are scikit-learn Pipeline objects you load with joblib and call predict_proba on.
ROC and Precision-Recall curves on the held-out test split (n=10 501, balanced). LightGBM (main) vs RandomForest (baseline), AUROC / PR-AUC computed from real predictions.
Metrics
Held-out test split (n=10 501, balanced target). Values are computed from real predict_proba outputs; F1 is reported at both the default 0.5 threshold and at the validation-set F1-optimal threshold t*.
| Model | ROC-AUC | PR-AUC | F1 @ 0.5 | F1 @ t* | Brier | t* |
|---|---|---|---|---|---|---|
| LightGBM (main) | 79.8% | 78.4% | 71.7% | 73.9% | 0.182 | 0.35 |
| RandomForest (baseline) | 79.5% | 77.9% | 70.8% | 73.2% | 0.184 | 0.41 |
A balanced 50/50 target means the no-skill baseline is 50% for both ROC-AUC and PR-AUC, so both models add roughly 28-30 points of real signal. LightGBM edges out the RandomForest baseline on every metric while staying well calibrated (Brier 0.182).
Visualizations
The ROC and Precision-Recall curves are shown at the top of this card. The two plots below cover calibration and feature attribution.
Calibration
Reliability curve of the LightGBM main model on the validation split (10 bins). Predicted probabilities track the diagonal closely, so the scores are usable as risk estimates rather than just rankings.
SHAP feature importance
Global SHAP summary for the LightGBM main model. Systolic blood pressure (ap_hi) dominates, followed by age and cholesterol, matching clinical intuition.
Feature order (11)
age (years), gender (1=female, 2=male), height (cm), weight (kg), ap_hi (systolic BP mmHg), ap_lo (diastolic BP mmHg), cholesterol (1=normal, 2=above, 3=well-above), gluc (1-3 same scale), smoke (0/1), alco (0/1), active (0/1).
Any field may be null - LightGBM handles NaN natively; the RandomForest pipeline imputes with the training-set median. Input is coerced to float at serve-time.
Top SHAP drivers (global, on validation)
ap_hi(systolic blood pressure) - dominantagecholesterolweightap_lo
Usage
from huggingface_hub import hf_hub_download
import joblib, pandas as pd
path = hf_hub_download(repo_id="kiselyovd/cardio-risk-rf", filename="cardio_risk_lgbm.joblib")
model = joblib.load(path)
x = pd.DataFrame([{"age": 56.0, "gender": 1.0, "height": 152.0, "weight": 72.0, "ap_hi": 160.0, "ap_lo": 90.0, "cholesterol": 3.0, "gluc": 1.0, "smoke": 0.0, "alco": 0.0, "active": 1.0}])
print(model.predict_proba(x))
Intended use
Educational artifact demonstrating a production-grade tabular ML pipeline (LightGBM + SHAP + FastAPI + Docker + HF Hub). Not a medical device. Do not use it for clinical decisions. The cardio target is cross-sectional (presence at examination), not a prospective 10-year risk.
Source and license
Code, training pipeline and full docs: github.com/kiselyovd/cardio-risk-rf. Released under the MIT License. Dataset: sulianova Cardiovascular Disease Dataset.
- Downloads last month
- -
Evaluation results
- roc_auc on sulianova Cardiovascular Disease Datasetself-reported0.798
- pr_auc on sulianova Cardiovascular Disease Datasetself-reported0.784
- f1 on sulianova Cardiovascular Disease Datasetself-reported0.717
- brier on sulianova Cardiovascular Disease Datasetself-reported0.182


