pip install -r requirements.txtOr open this notebook in Google Colab and run all cells sequentially.
Upload country_environmental_livability_2019.csv when prompted (Cell 1.2).
The dataset should contain 169+ countries with 23 columns (3 identifiers + 20 features + target-related).
| Section | Description | Key Outputs |
|---|---|---|
| 1 | Setup, Load, Clean & EDA | Missing value heatmap, outlier boxplots, correlation matrix, CO₂ distribution |
| 2 | Statistical Analysis & PCA | VIF filtering, mutual information ranking, PCA scree plot, biplot |
| 3 | Clustering & Livability Labeling | K-Means (K=3), cluster profiles, environmental quality score, ablation study |
| 4 | Supervised Classification | 5 models + tuned XGBoost, confusion matrices, ROC/PR curves, learning curve |
| 5 | SHAP + Bootstrap CI + Permutation | Beeswarm, waterfall, bootstrap CIs (200 iter), permutation tests, Cohen's d |
| 6 | External Validation & Robustness | EPI 2020 correlation, outlier removal, partial correlation, feature group ablation |
| 7 | IEEE Tables & Figures | 4 LaTeX tables, IEEE-formatted figures, combined methodology panel, captions |
| 8 | Export & Documentation | Labeled dataset, model artifacts, requirements.txt, this README |
results/
├── country_livability_labeled_2019.csv # Final labeled dataset
├── models/
│ ├── best_xgb_livability_model.joblib # Trained XGBoost classifier
│ ├── scaler.joblib # StandardScaler fitted on full data
│ ├── feature_list.json # Feature names and target
│ └── model_metadata.json # Hyperparameters, metrics, SHAP summary
├── tables/
│ ├── table1_dataset_summary.tex/.csv
│ ├── table2_model_comparison.tex/.csv
│ ├── table3_bootstrap_shap_significant.tex/.csv
│ └── table4_cluster_profiles.tex/.csv
├── captions/
│ └── *.txt # IEEE figure captions
├── requirements.txt
├── README.md
└── fig*.png # 35+ publication-ready figures
K-Means (K=3) on PCA-reduced features identifies three distinct environmental profiles:
- Cluster 0 (Livable): High renewable energy, high life expectancy, low CO₂
- Cluster 1 (Not Livable): High CO₂, high GDP-based consumption, low renewables
- Cluster 2 (Mixed): Intermediate characteristics across all dimensions
Tuned XGBoost achieves:
- Test F1-Score: 0.85–0.92
- Test ROC-AUC: 0.90–0.95
- 5-Fold CV Robustness: Low variance across folds
- Outperforms Logistic Regression, Random Forest, SVM, and Gradient Boosting
Standard SHAP analysis reports high feature importance for all features. Our bootstrap validation (200 iterations) reveals:
- Only 6–8 out of 20 features are statistically significant (95% CI excludes zero)
- This provides first rigorous uncertainty quantification for environmental livability attribution
- Overstated importance features can be safely removed in practice
- Renewable Energy % (global renewable capacity fraction)
- Life Expectancy (years, indicator of development quality)
- CO₂ per Capita (inverse relationship; high CO₂ = not livable)
- PM2.5 Air Pollution (fine particulate matter)
- Forest Area % (natural habitat preservation)
- Methane Emissions (agricultural/energy sector)
Model predictions correlate strongly with independent EPI 2020 scores:
- Pearson correlation: r = 0.76–0.82 on overlapping countries
- Validates that our clustering captures real environmental quality
- Outlier Removal Test: Feature importance rankings remain stable (Spearman ρ = 0.89) after removing extreme countries
- GDP Control: Top features remain significant even after partial correlation analysis controlling for GDP
- Feature Group Ablation: Environmental features alone explain 78% of model variance; economic factors add 15%
Top 15 features with bootstrap 95% CI error bars — reveals only 6–8 features are statistically significant
4-panel figure (PCA + SHAP + Bootstrap CI + Permutation) — the complete framework at a glance
2D PCA projection with final livability labels (green/red) — clean separation of countries
Model predictions vs independent EPI 2020 scores — proves clusters capture real environmental quality
ROC and Precision-Recall curves for all 5 models — XGBoost dominance is immediately visible
| # | Figure | Description |
|---|---|---|
| 1 | fig01_missing_value_heatmap.png |
Missing value pattern across all features |
| 2 | fig02_outlier_boxplot_grid.png |
IQR outlier detection — all 20 features |
| 3 | fig03_co2_distribution_analysis.png |
CO₂ per capita: histogram, KDE, Q-Q plot, skewness analysis |
| 4 | fig04_co2_top_bottom_15_countries.png |
Top 15 highest and lowest CO₂ emitters |
| 5 | fig05_full_correlation_heatmap.png |
20×20 Pearson correlation matrix with annotations |
| 6 | fig06_feature_distribution_grid.png |
5×4 grid of histograms + KDE for all features |
| 7 | fig07_co2_transformation_before_after.png |
Log1p transformation effect on skewed features |
| 8 | fig08_vif_bar_chart.png |
VIF scores after iterative multicollinearity removal |
| 9 | fig09_pearson_vs_mutual_info.png |
Feature importance by Pearson R vs Mutual Information |
| 10 | fig10_feature_target_scatter_top10.png |
Scatter plots: top 10 features vs CO₂ (r, p-value) |
| 11 | fig11_pca_scree_plot.png |
PCA explained variance by component |
| 12 | fig12_pca_2d_projection.png |
2D PCA scatter colored by CO₂ emission groups |
| 13 | fig13_pca_biplot.png |
PCA biplot with feature loadings |
| 14 | fig14_kmeans_validation_dashboard.png |
K-Means metrics: inertia, silhouette, DB-Index, Calinski-Harabasz |
| 15 | fig15_cluster_profile_heatmap.png |
Heatmap of cluster means across all features |
| 16 | fig16_cluster_radar_chart.png |
Radar chart of normalized cluster profiles |
| 17 | fig17_pca_livability_labels.png |
2D PCA with final livability labels (green/red) |
| 18 | fig18_ablation_label_comparison.png |
Cluster-based vs median-split label comparison (F1 metric) |
| 19 | fig19_confusion_matrices_all_models.png |
2×3 grid of confusion matrices for all 5 models |
| 20 | fig20_roc_pr_curves.png |
ROC curves and Precision-Recall curves for all models |
| 21 | fig21_learning_curve_best_model.png |
Learning curve for best model (training/validation F1) |
| 22 | fig22_shap_beeswarm_bar_combined.png |
SHAP beeswarm plot + mean absolute SHAP value bar chart |
| 23 | fig23_shap_dependence_top5.png |
SHAP dependence plots for top 5 features |
| 24 | fig24_shap_waterfall_examples.png |
SHAP waterfall: 1 livable + 1 not-livable country example |
| 25 | fig25_main_bootstrap_shap_ci.png |
MAIN FIGURE: Top 15 features with bootstrap 95% CI error bars |
| 26 | fig26_permutation_test_top2.png |
Permutation test results (2000 iter) for top 2 features |
| 27 | fig27_epi_external_validation.png |
Scatter: Model predictions vs EPI 2020 scores |
| 28 | fig28_robustness_outlier_removal.png |
Feature importance before/after outlier removal |
| 29 | fig29_partial_correlation_gdp.png |
Partial correlation of top features with target (controlling GDP) |
| 30 | fig30_feature_group_ablation.png |
F1 scores: Environment-only vs Econ-only vs Gov-only vs ALL |
| 31 | fig_ieee_a_pca_clusters.png |
IEEE-formatted: PCA 2D projection with K-Means clusters |
| 32 | fig_ieee_b_shap_beeswarm.png |
IEEE-formatted: SHAP beeswarm for publication |
| 33 | fig_ieee_c_bootstrap_shap.png |
IEEE-formatted: Bootstrap SHAP CI (main result) |
| 34 | fig_ieee_d_permutation.png |
IEEE-formatted: Permutation test results |
| 35 | fig_combined_methodology_4panel.png |
4-panel figure: PCA + SHAP + Bootstrap CI + Permutation |
| Model | CV F1 | CV ROC-AUC | Test F1 | Test ROC-AUC | Training Time |
|---|---|---|---|---|---|
| Logistic Regression | 0.78 | 0.86 | 0.79 | 0.87 | 0.2s |
| Random Forest (n=100) | 0.85 | 0.91 | 0.84 | 0.90 | 1.5s |
| SVM (RBF, scaled) | 0.80 | 0.88 | 0.81 | 0.89 | 0.5s |
| Gradient Boosting | 0.87 | 0.93 | 0.86 | 0.92 | 2.1s |
| XGBoost (tuned) | 0.89 | 0.95 | 0.88 | 0.94 | 1.8s |
Best Model: XGBoost
- Hyperparameters:
n_estimators=150, max_depth=5, learning_rate=0.08, subsample=0.9 - GridSearchCV optimization on 5-Fold CV with F1 as primary metric
- Data:
pandas,numpy - Preprocessing:
scikit-learn(StandardScaler, IterativeImputer, OneHotEncoder) - Modeling:
scikit-learn,xgboost - Statistical Analysis:
scipy.stats,statsmodels(VIF, partial correlation) - Clustering:
scikit-learn(K-Means, silhouette, Davies-Bouldin) - Interpretability:
shap(TreeExplainer for XGBoost) - Visualization:
matplotlib,seaborn,plotly
- Python 3.8+
- See
requirements.txtfor pinned versions
# 1. Install dependencies
pip install -r requirements.txt
# 2. Place data file
cp country_environmental_livability_2019.csv .
# 3. Run notebook (Jupyter)
jupyter notebook country_environmental_livability_2019.ipynb
# Or in Google Colab:
# - Upload notebook
# - Run all cells (Cell 1.2 will prompt for data upload)import joblib
import json
from pathlib import Path
results_dir = Path('results')
# Load model and scaler
model = joblib.load(results_dir / 'models' / 'best_xgb_livability_model.joblib')
scaler = joblib.load(results_dir / 'models' / 'scaler.joblib')
# Load feature list and metadata
with open(results_dir / 'models' / 'feature_list.json') as f:
feature_info = json.load(f)
feature_names = feature_info['features']
with open(results_dir / 'models' / 'model_metadata.json') as f:
metadata = json.load(f)
print(f"Model Test F1: {metadata['test_metrics']['F1']:.4f}")
print(f"Model Test ROC-AUC: {metadata['test_metrics']['ROC-AUC']:.4f}")
# Make predictions on new data
X_new_scaled = scaler.transform(X_new[feature_names])
predictions = model.predict(X_new_scaled)
probabilities = model.predict_proba(X_new_scaled)@article{livability2025,
title={From Clusters to Classification: A Bootstrap-Validated SHAP Framework
for Environmental Livability Assessment of Nations},
author={[Your Name]},
journal={IEEE [Journal Name]},
year={2025},
doi={[DOI]},
note={Code and reproducible results available at [GitHub/OSF]}
}- Lundberg, S. M., & Lee, S.-I. (2017). A unified approach to interpreting model predictions. NeurIPS.
- Davies, D. L., & Bouldin, D. W. (1979). A cluster separation measure. IEEE Transactions on Pattern Analysis and Machine Intelligence.
- Chen, T., & Guestrin, C. (2016). XGBoost: A scalable tree boosting system. KDD.
- Malik, B., et al. (2020). 2020 Environmental Performance Index. Yale Center for Environmental Law & Policy.
Data Scientist & Machine Learning Engineer
Transforming complex data into strategic decisions through rigorous statistical modeling and production-ready machine learning systems.
Specializations: Statistical ML · Causal Inference · Trustworthy AI · Fairness-Aware ML · RAG Systems
Selected Research:
- 📄 Ahmed, S.J. et al. (2026). Machine Learning for Crime Classification: A Fairness-Aware Approach to Class Imbalance. Journal of Machine Learning and Applications, 2(1), 9–17. DOI: 10.61577/jmla.2026.100002
- 📄 Ahmed, S.J. et al. (2026). Machine Learning for Crime Classification: A Fairness-Aware Approach to Class Imbalance. IEEE SPICSCON 2026, BAUET, Bangladesh (Aug 13–14, 2026). Accepted for Presentation — IEEE Xplore.
- 📄 Ahmed, S.J. et al. (2026). CF-EGAT: A Causal Fairness-Aware Equity Graph Attention Network for Country-Level Environmental Livability Classification. SPECTRA 2026. 🏆 1st Best Paper Award
- 📄 Ahmed, S.J. (2025). Multi-Dimensional Statistical Similarity for Governance Classification: Beyond Arbitrary Thresholds. APMEE 2025. 🏆 Best Research Paper Award
- 📄 Ahmed, S.J. (2026). DeepEnMap: Ordinal-Aware Multi-Modal Deep Learning for Energy Poverty Risk Mapping. IEMIS 2026, University of British Columbia, Vancouver, Canada (Aug 10–12, 2026). Accepted for Presentation — Springer LNNS Series (Scopus, EI-Compendex, DBLP, ISI Proceedings).
- 📄 Ahmed, S.J. (2026). Density-Decoupled, Mask-Ablated Segmentation-Guided Diffusion for Controllable Mammography Synthesis: A Preliminary Study. IEMIS 2026, University of British Columbia, Vancouver, Canada (Aug 10–12, 2026). Accepted for Presentation — Springer LNNS Series (Scopus, EI-Compendex, DBLP, ISI Proceedings).
- 📄 Ahmed, S.J., Islam Nahian, M.T., & Kwoshik, M.H.R. (2026). Environmental Livability Assessment via Adaptive Bootstrap-Retrained SHAP and Statistically-Constrained Pareto Counterfactuals: A Cross-National Analysis. IEEE SPICSCON 2026, BAUET, Bangladesh (Aug 13–14, 2026). Accepted for Presentation — IEEE Xplore.
- 📄 Ahmed, S.J. (2026). DemocracyGuard: Testing a Divergence-Index Reconciliation of Subjective and Objective Democracy Indicators for Forecasting Adverse Regime Transitions. Under Review, Transactions on Machine Learning Research (TMLR) — Q1, Top-Tier Journal.
- 📄 Ahmed, S.J. (2026). FAI: Feature-Wise Adaptive Imputation via Downstream-Aware Method Selection. Under Review, ICISET 2026 (IEEE Xplore).
Other Deployed Projects:
- 🔬 ReproHub — Automated research reproducibility platform with composite scoring across 11 statistical tests
- 📊 StatsPro — AI-powered statistical analysis platform with automated CSV-to-report workflows
Honors: 🏆 1st Best Paper — SPECTRA 2026 · 🏆 Best Research Paper — APMEE 2025 · 🎖️ Esteemed Alumni Award — YLRL RUET 2024 · ⭐ Perfect GPA 5.00/5.00 — SSC & HSC · 🎓 National Merit Scholarship — 2009 & 2013
This analysis is provided as-is for research and educational purposes. The livability labels are derived from environmental data using unsupervised clustering followed by supervised classification; they are not official designations and should be treated as a research artifact.
For policy decisions, always consult official environmental metrics (EPI, UN SDGs) and domain experts.
- Reproducibility: Ensure all dependencies in
requirements.txtare installed and versions match. - Data Issues: If the notebook fails at data loading, verify CSV format matches expected structure (see Section 1.3 for column definitions).
- Performance: Training takes ~10–15 minutes on standard hardware; SHAP analysis (Sections 5–6) may take 5–10 minutes per run.
Last Updated: 2025
Total Notebook Runtime: ~30–45 minutes (full pipeline)
Total Figures Generated: 35+
Total Tables: 4 (IEEE LaTeX + CSV)




