Skip to content

Repository files navigation

🧠 Stroke Risk Intelligence — End-to-End Clinical ML Pipeline & Dashboard in R

An end-to-end predictive analytics project built in R on the public Stroke Prediction Dataset. It goes beyond a single model — combining formal statistical inference, five tuned machine learning architectures, rigorous model evaluation, and a live interactive dashboard.

🔗 Live demo: [add your shinyapps.io link here] 🎥 Video walkthrough: [add a link to your LinkedIn post or YouTube upload here, optional]

⚠️ Disclaimer: This is an educational / portfolio project built on a public dataset. It is not a validated clinical tool and must never be used for real medical decisions.


📊 What's inside

1. Statistical Inference

  • Chi-square tests + Cramér's V for categorical predictors
  • Welch t-tests + Cohen's d for continuous predictors
  • Univariate logistic regression odds ratios with 95% confidence intervals

2. Machine Learning Models

  • 5 tuned architectures (5-fold stratified cross-validation, grid search): Logistic Regression, Elastic Net, Decision Tree, Random Forest, XGBoost
  • 2 exploratory models benchmarked for reference: SVM (radial kernel), Naive Bayes

3. Model Evaluation

  • ROC AUC, PR AUC, accuracy, sensitivity, specificity, precision, F1, balanced accuracy, MCC, Brier score
  • Bootstrapped 95% confidence intervals for AUC
  • DeLong test to check whether the gap between the top two models is statistically significant
  • Calibration curves and confusion matrices

4. Interactive Dashboard (built with shiny + shinydashboard)

  • Risk Calculator — enter patient details and get a live stroke-risk prediction, risk category, and percentile vs. the test cohort
  • Population Explorer — filterable distributions and correlation heatmap across the dataset
  • Model Performance — side-by-side metrics, ROC curves, calibration curves, and confusion matrices for every model
  • Statistical Insights — all inference tables plus Random Forest / XGBoost variable importance

🖥️ Tech stack

R · tidymodels · xgboost · randomForest · glmnet · shiny · shinydashboard · plotly · DT · pROC · broom


🚀 Running it locally

# Clone the repo, then open the .Rmd in RStudio and click "Run Document"
# (or from the R console:)
rmarkdown::run("Build-deploy-stroke-prediction-model-R.Rmd")

All required packages are auto-installed on first run. Make sure healthcare-dataset-stroke-data.csv is in the same folder as the .Rmd file.


🌐 Deploying your own live copy (shinyapps.io)

install.packages("rsconnect")
rsconnect::setAccountInfo(name="your-account", token="XXXX", secret="XXXX")
rsconnect::deployApp(appDir = ".")

📁 Files

File Description
Build-deploy-stroke-prediction-model-R.Rmd Full analysis + dashboard source code
healthcare-dataset-stroke-data.csv Dataset (Kaggle, WHO-motivated)

📌 Key findings

  • The dataset is severely imbalanced (~5% positive class), so evaluation centers on sensitivity, ROC AUC, balanced accuracy, and MCC rather than raw accuracy.
  • Age, hypertension, heart disease, and average glucose level show the strongest, most significant associations with stroke — consistent with established cerebrovascular risk literature.
  • Variable importance from the tree-based models converges with the statistical inference layer, cross-validating the findings across two independent methods.

🔮 Future improvements

  • Apply SMOTE or class-weighted losses during training to directly address class imbalance
  • Add SHAP-based local explanations for individual predictions
  • Expand deployment with authentication for multi-user clinical demo scenarios

👤 Author

Masum Abbas Feel free to connect or open an issue if you spot something worth improving.

About

End-to-end stroke risk prediction pipeline in R: statistical inference (chi-square, t-tests, odds ratios), 5 tuned ML models (LogReg, Elastic Net, Decision Tree, Random Forest, XGBoost) + 2 exploratory, evaluated with ROC/calibration/DeLong tests, deployed as an interactive Shiny dashboard. Educational project, not for clinical use.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors