Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Late-Stage Cancer Diagnosis Prediction

Machine Learning + NHS Healthcare Analytics on Simulacrum v2.0

A binary classifier that predicts late-stage (Stage III/IV) cancer diagnosis at the patient level using the publicly available Simulacrum v2.0 simulated cancer registry. Built on 1.17M+ records across 1.13M unique patients, it pairs three interpretable models (Logistic Regression, Random Forest, Gradient Boosting) with class-imbalance correction, patient-level cross-validation, and SHAP interpretability.


At a glance

Stage Recall ROC-AUC F1 Notes
Baseline Gradient Boosting 35% 0.68 0.42 Class imbalance ignored
+ Engineered features + Balanced class weights 75.2% 0.68 0.61 Headline result
+ Threshold tuning on Logistic Regression 88.6% 0.68 0.59 Highest recall configuration

ROC-AUC of 0.68 reflects the realistic ceiling for late-stage cancer prediction from registry-level features alone. This work prioritises recall (catching late-stage cases that need earlier intervention) over precision, which matches the clinical risk asymmetry: missing a late-stage case is more costly than a false alarm in a screening context.

Baseline confusion matrices


Project context

This project was completed as part of a work experience placement at NHS England, contributing to ongoing work on cancer pathway analytics. It is exploratory analysis and has not been quality assured. The work is uploaded here as a personal portfolio exercise with the explicit permission of the supervising team.

The framing question, can patient-level data predict who is at risk of late-stage diagnosis early enough to inform screening or referral pathways, is informed by the NHS Long Term Plan goal of reducing late-stage cancer diagnosis from approximately 43% to 25% by 2029.


What's in this repo

cancer-late-stage-prediction/
├── Cancer_Late_Stage_Prediction.ipynb   The full Jupyter notebook (37 cells)
├── README.md                             This file
├── MODEL_CARD.md                         Model card: intended use, performance, limitations, ethics
├── requirements.txt                      All Python dependencies
├── figures/                              13 rendered figures from the notebook
│   ├── 01-02 Data overview, missingness
│   ├── 03    Target class distribution
│   ├── 04-09 EDA: late-stage rate by gender, age, comorbidity, IMD, ethnicity, pulmonary disease
│   ├── 10-11 Correlation analysis and full heatmap
│   ├── 12    Risk score by age band and gender
│   └── 13    Baseline confusion matrices (3 models)
└── .gitignore

The Simulacrum v2.0 dataset is not redistributed in this repository (it is sizeable and has its own licence terms). Download links are below.


The pipeline in one paragraph

The two source tables (sim_av_patient with 1.87M demographic records and sim_av_tumour with 1.99M tumour records) are merged on patientid, producing a 1.99M-row joined table. After filtering to records with a known stage and a clean diagnosis, the analysis-ready dataset is 1,176,315 rows across 12 columns. A patient-level train/test split (80/20) ensures no patient appears in both train and test (939,486 training samples from 902,037 patients, 235,008 test samples from 225,510 patients). Eight engineered features are added (age squared, age log, age over 65, male × age interaction, age × pulmonary, age × diabetes, age × Charlson, elderly multimorbid flag), bringing the feature count from 39 to 47. Three models are trained at baseline and again under each of three imbalance-correction strategies (balanced class weights, SMOTE oversampling, threshold tuning). Robustness is tested via 5-fold GroupKFold cross-validation, where the grouping key is the patient ID so no patient leaks between folds. SHAP analysis identifies age-related features as accounting for roughly 89% of model-attributed importance, with comorbidity and IMD contributing the remainder.


Key analytical findings

Age dominates, but it is not the whole story

Age accounts for roughly 89% of feature importance. The single largest jump in late-stage rate occurs at age 75+ with multiple comorbidities, which the engineered elderly_multimorbid flag captures explicitly.

Late-stage rate by age band

A meaningful gender disparity

Late-stage rate is approximately 59% higher among men in the dataset. This is reflected in the engineered male_age_risk feature, which captures the interaction between male sex and age. The fairness implications of this are discussed in the model card.

Late-stage rate by gender

Imbalance handling moves the needle most for recall

Switching from baseline class weights to balanced class weighting and SMOTE more than doubles recall (from 36% to 75%). With aggressive threshold tuning on Logistic Regression, recall reaches 88.6%, with the trade-off that precision falls. In a screening context, this trade-off is usually worth taking.

Patient-level cross-validation is non-negotiable

Random row-level splits leak the same patient across train and test, since most patients have multiple tumour records in the registry. GroupKFold on patientid is essential and is applied throughout.


How to reproduce

Option 1: Open in Google Colab (recommended)

The notebook was developed in Colab. Click the badge below to open it:

Open In Colab

You will need to download the Simulacrum v2.0 dataset (see Data section below) and upload sim_av_patient.csv and sim_av_tumour.csv to your Colab session, or to your Google Drive at My Drive/simulacrum/.

Option 2: Run locally

git clone https://github.com/Mulualem03/cancer-late-stage-prediction.git
cd cancer-late-stage-prediction

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# Download Simulacrum v2.0 (see Data section), and place
# sim_av_patient.csv and sim_av_tumour.csv in a folder you can point the notebook at

jupyter notebook Cancer_Late_Stage_Prediction.ipynb

Data

This project uses the publicly available Simulacrum v2.0 synthetic cancer dataset, released by NHS Digital and Public Health England.

Source: https://simulacrum.healthdatainsight.org.uk/

The Simulacrum is a synthetic dataset designed to closely resemble the real National Cancer Registration Dataset (NCRAS). It does not contain any real patient data, but its statistical structure mirrors the real registry. It is intended to support exploratory analysis, methods development, and code testing without the governance overhead of accessing the real registry.

The dataset is not redistributed in this repository. Download it from the Simulacrum portal and place the files where the notebook expects them.


Limitations and ethical considerations

See MODEL_CARD.md for the full Mitchell-format model card. Headline points:

  1. This is exploratory analysis, not quality assured. It has not undergone formal model validation, clinical safety review, regulatory approval, or external benchmarking. It is a personal portfolio piece using public synthetic data and should be treated as such.

  2. Simulacrum is synthetic. While calibrated to match the real National Cancer Registration Dataset, it does not capture every nuance of the real population. Generalisation to live registry data is plausible but unproven.

  3. AUC of 0.68 is the realistic ceiling for this feature set. Higher AUC would require richer clinical features (e.g. imaging biomarkers, full pathology, GP records) than the Simulacrum provides.

  4. Gender disparity is captured but not mitigated. The male_age_risk feature increases predictive performance but may mean the model is more sensitive for one group than another. A real deployment would need to apply formal fairness metrics and mitigation techniques.

  5. The model is not a clinical decision tool. It cannot be used to support individual patient care decisions without independent validation and regulatory review.


Built by

Mulualem Kahssay, May 2026.

About

ML pipeline predicting late-stage (Stage III/IV) cancer diagnosis on 1.17M+ Simulacrum v2.0 records. Logistic Regression, Random Forest, Gradient Boosting compared with SMOTE and class weight balancing. 88.6% recall, AUC 0.68, with SHAP interpretability. Personal exploratory analysis from NHSE work experience, not quality assured.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages