Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Infection Risk Prediction using Machine Learning

Python scikit-learn Pandas Jupyter Status

📖 Executive Summary (About)

This project is an end-to-end machine learning case study for predicting whether an individual has a high risk of COVID-19 infection based on demographic, behavioural, exposure, and health-condition attributes. It converts a raw public-health survey dataset into a structured predictive analytics workflow that covers data profiling, leakage control, missing-value treatment, feature engineering, model comparison, threshold tuning, and decision-focused reporting.

The business problem is early infection-risk prioritisation: given limited healthcare and public-health resources, the model helps identify people whose survey profile indicates elevated infection risk. The analysis is designed not only to maximise classification performance, but also to support explainable decision-making through interpretable baselines, ROC/AUC comparison, feature-importance analysis, and threshold selection.

The final report selects a soft-voting ensemble combining Logistic Regression, Decision Tree, and Neural Network models for decision-making. On the held-out test set, the ensemble achieved approximately 0.995 accuracy and 0.9997 ROC-AUC in the report, with threshold tuning improving the sensitivity-specificity balance. The latest notebook run also records an optimised ensemble threshold with 0.998 accuracy, 1.000 precision, 0.996 recall, and 0.998 F1 for the high-risk class.

🚀 Technical Highlights & Business Value

  • Full ML lifecycle execution: Ingests a 5,000-row, 43-column health-risk dataset and builds a complete supervised classification workflow from raw data to final decision recommendation.
  • Leakage-aware feature governance: Removes post-outcome or non-actionable variables such as risk_mortality, survey date, and granular geolocation fields before modelling.
  • Robust preprocessing strategy: Handles high-missingness features, median/mode imputation, missingness flags, categorical encoding, scaling, and stratified train/test splitting.
  • Model benchmarking at executive standard: Compares tuned Decision Tree, Logistic Regression, PCA-based Logistic Regression, Neural Network, feature-selected Neural Network, and soft-voting Ensemble models using Accuracy, ROC-AUC, Precision, Recall, F1, and confusion matrices.
  • Decision-ready threshold optimisation: Evaluates default, Youden's J, and F1-max thresholds so the model can be tuned for balanced screening, missed-positive minimisation, or false-alarm control.

🛠️ Tech Stack & Skills Demonstrated

  • Languages: Python
  • Frameworks & Libraries: Pandas, NumPy, scikit-learn, Matplotlib, Seaborn, Jupyter Notebook, Graphviz, pydot
  • Methodologies: Supervised Classification, Exploratory Data Analysis, Data Cleaning, Missing-Value Imputation, One-Hot Encoding, Standardisation, Stratified Sampling, GridSearchCV, PCA, RFECV, Feature Selection, Soft Voting Ensembles, ROC Analysis, Youden's J Threshold Optimisation
  • Domain Skills: Public Health Analytics, Infection-Risk Stratification, Clinical Decision Support, Predictive Modelling, Model Explainability, Performance Benchmarking, Data Quality Assessment

🔑 Keywords & Tags

infection risk prediction, COVID-19 analytics, public health machine learning, supervised classification, healthcare analytics, scikit-learn, logistic regression, decision tree, neural network, soft voting ensemble, ROC-AUC, threshold tuning, feature engineering, model explainability, predictive analytics

🏗️ Architecture & Methodology

The project begins with data/raw/covid-prediction.csv, a 5,000-record survey dataset with 43 variables spanning geography, demographics, behavioural exposure, contact patterns, symptoms, COVID-positive status, comorbidities, and risk scores. The target variable is risk_infection, with a near-balanced class distribution of 2,536 low-risk and 2,464 high-risk responders.

The preprocessing phase is intentionally leakage-aware. Variables that could distort real-world deployment or duplicate downstream knowledge are removed, including risk_mortality, survey_date, ip_latitude, ip_longitude, and ip_accuracy. The modelling dataset retains 38 selected variables before encoding. Numeric missing values are handled using median-based strategies, categorical gaps use mode or explicit missing categories, and high-missingness variables such as drug-use fields are supported with missingness indicators.

The modelling workflow uses an 80/20 stratified train/test split, producing 4,000 training rows and 1,000 test rows while preserving the target distribution. Baselines and tuned models are then trained across multiple families: Decision Trees for transparent rules, Logistic Regression for calibrated and interpretable linear decision-making, PCA-based Logistic Regression for dimensionality reduction, Multi-Layer Perceptrons for non-linear interactions, and a soft-voting ensemble to combine complementary inductive biases.

Evaluation is performed with both predictive and decision metrics. The notebook and report track accuracy, ROC-AUC, class-level precision/recall/F1, confusion matrices, ROC curves, feature importance, coefficient directionality, model ranking tables, and threshold comparisons. The final decision workflow recommends the soft-voting ensemble when maximising predictive robustness, while also documenting Logistic Regression as a highly interpretable alternative.

📊 Model Performance Summary

Model Test Accuracy Test ROC-AUC Notes
Decision Tree (Tuned) 0.995 0.9983 Transparent rule-based baseline
Logistic Regression (Tuned) 0.994-0.996 0.9997 Strong interpretable model
Neural Network (Tuned) 0.987-0.990 0.9991 Non-linear benchmark
NN with RFECV Features 0.994 0.9998 12-input feature-selected NN
Soft Voting Ensemble 0.995-0.998 0.9997 Final decision model with threshold tuning

Key high-risk signals identified across models include recent COVID-19 positive status, COVID-19 symptoms, known COVID-19 contact, nursing-home exposure, public transport count, critical travel for work, household size, and selected comorbidities.

📂 Repository Structure

Infection-Risk-Prediction-ML/
|-- README.md                         # Project documentation
|-- data/
|   `-- raw/
|       `-- covid-prediction.csv      # Raw survey dataset
|-- notebooks/
|   `-- infection_risk_analysis.ipynb # Full modelling notebook
`-- reports/
    `-- assessment1-report.pdf        # Final analytical report

▶️ How to Reproduce

  1. Clone the repository.
git clone https://github.com/Vigodang/Infection-Risk-Prediction-ML.git
cd Infection-Risk-Prediction-ML
  1. Install the core Python dependencies.
pip install pandas numpy scikit-learn matplotlib seaborn jupyter graphviz pydot
  1. Open and run the notebook.
jupyter notebook notebooks/infection_risk_analysis.ipynb

The notebook performs the full workflow: dataset profiling, preprocessing, train/test split, model training, hyperparameter tuning, ROC analysis, feature selection, ensemble comparison, and final threshold selection.

📌 Project Outcome

This repository demonstrates the ability to transform a messy real-world health dataset into a defensible machine learning decision system. The final ensemble model delivers near-perfect separability on the held-out test set, while the broader analysis preserves professional judgement through leakage control, interpretable baselines, transparent threshold trade-offs, and reporting suitable for both technical and stakeholder audiences.

About

A complete end-to-end machine learning workflow for predicting infection risk using demographic and health-related features. This repository covers exploratory data analysis (EDA), feature engineering, model building, evaluation metrics, and reporting for an academic case study.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages