The need
Venous thromboembolic disease covers deep vein thrombosis and pulmonary embolism. Anticoagulants prevent new clots but raise the risk of bleeding, so doctors must weigh the risk of recurrence against the risk of treatment for each patient.
The hospital’s request changed during the project: it now wanted a model doctors could understand and question, since a score with no justification does not fit medical practice. So we restarted the AI work from scratch and built on the existing application.
What I owned
The whole AI pipeline, as part of a team of five: understanding the medical data, preprocessing, modelling, evaluation, explainability and integration into the application.
The solution
A binary classifier predicts recurrence from clinical and demographic variables, and returns a probability along with the reasons behind it.
How it was built
Three decisions matter most:
- Handling imbalance. Under 15% of patients recur. A plain model scores high accuracy but misses them, so we used SMOTENC, which respects both categorical and numeric variables.
- Tuning the threshold. The decision threshold was set from the precision-recall curve to maximise F1, ending at 0.32 and not the default 0.5.
- Explaining decisions. SHAP checks that the model’s drivers make medical sense. LIME justifies each individual prediction for the doctor.
Results
- XGBoost was the best model, with a weighted F1 of 0.93 and accuracy of 0.93.
- On the rare class that matters, it detected 37 of 46 recurrences, with an F1 of 0.73 for that class. This is the honest measure of performance, since the weighted score is lifted by the majority class.
- Fast enough for live use, at about 15 ms per prediction.
- XGBoost covers almost the whole radar, with high scores on every axis, while Random Forest gives up ground on the recurrence class.
- The most influential variables, such as years of risk exposure, treatment duration and BMI, are consistent with clinical knowledge.