A live machine learning app that predicts which GP practices will overspend on NHS prescribing. Upload a real NHS prescribing file and get back a ranked list of at-risk practices built with a Random Forest model that is 95.4% accurate.
Upload a raw NHS prescribing file → the app cleans it, runs the model, and shows you which GP practices are predicted to overspend.
This is a machine learning web app that acts as an early warning tool for NHS prescribing overspending. The NHS currently finds out about overspending only after the money is gone. This app predicts it ahead of time.
You upload a raw monthly prescribing file from the NHS Business Services Authority (NHSBSA) Open Data Portal. The app does everything else:
- Cleans the raw data automatically (the same cleaning pipeline used to train the model).
- Groups it by practice, drug category and month.
- Predicts the expected cost for each practice using a trained Random Forest model.
- Flags at-risk practices where actual spending is more than 20% above what the model predicted.
- Shows a ranked chart and lets you download the results as a CSV.
- Random Forest Regressor trained on NHS EPD SNOMED 2025 data.
- 95.4% accuracy (R² = 0.954) on held-out November–December test data.
- Beats a Linear Regression baseline (R² = 0.55) by 40 percentage points, because prescribing cost is driven by non-linear interactions between drug category, volume and pricing.
- Cross-validated (5-fold) with a mean R² of 0.966 and a standard deviation of just 0.0006, the model is stable across different data splits.
- Identified 2,417 at-risk GP practices in the test period.
The single biggest predictor is prescription volume (ITEMS, 61%), followed by drug category (16%). Together they explain 77% of all cost variation. Geographic location adds less than 1% confirming that prescribing cost depends on what is prescribed, not where.
- Go to the NHSBSA Open Data Portal.
- Open a monthly EPD SNOMED file and use the filter to download data for a single ICB (this keeps the file small enough to upload).
- Open the live app and upload that file.
- Click Clean Data & Run Prediction.
- Review the at-risk practices and download the results.
The app is designed for single-ICB monthly extracts. The full national file is too large to upload on a free hosting tier.
- scikit-learn - Random Forest model and label encoders
- Streamlit - the web app
- pandas - data cleaning and aggregation
- Plotly - the at-risk practices chart
- joblib - saving and loading the trained model
- Streamlit Community Cloud - hosting
The model is trained on eight features, built by grouping raw prescribing rows by practice, ICB, drug category, month and quarter:
total_items, total_quantity, total_adq, avg_nic_ratio, ICB_CODE (encoded), BNF_CHAPTER_CODE (encoded), MONTH, QUARTER
The target is total actual cost per practice, per drug category, per month.
# Clone the repository
git clone https://github.com/ArcticNavigator/NHS-prescribing-model.git
cd NHS-prescribing-model
# Install dependencies
pip install -r requirements.txt
# Run the app
streamlit run model_app.py- Full project → NHS-Prescribe-Seek (notebook, dashboard and model together)
- Interactive dashboard → NHS-prescribing-dashboard (explore all the findings)
English Prescribing Dataset (EPD) with SNOMED code - NHS Business Services Authority Open Data Portal: https://opendata.nhsbsa.net/dataset/english-prescribing-dataset-epd-with-snomed-code
Built by ArcticNavigator.
Keywords: NHS overspending prediction, machine learning healthcare, Random Forest model NHS, NHS prescribing prediction app, GP practice cost prediction, scikit-learn healthcare model, predictive analytics NHS, NHS EPD SNOMED machine learning, healthcare ML deployment, Streamlit machine learning app, NHS budget forecasting, prescribing cost model England, at-risk practice detection.