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.
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
R · tidymodels · xgboost · randomForest · glmnet · shiny · shinydashboard · plotly · DT · pROC · broom
# 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.
install.packages("rsconnect")
rsconnect::setAccountInfo(name="your-account", token="XXXX", secret="XXXX")
rsconnect::deployApp(appDir = ".")| File | Description |
|---|---|
Build-deploy-stroke-prediction-model-R.Rmd |
Full analysis + dashboard source code |
healthcare-dataset-stroke-data.csv |
Dataset (Kaggle, WHO-motivated) |
- 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.
- 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
Masum Abbas Feel free to connect or open an issue if you spot something worth improving.