Surgery Duration Prediction — PROBOCAL
A scikit-learn pipeline predicting real surgery duration from data available at scheduling time — benchmarked against the hospital's own human estimates.
Context
The goal was to help optimize operating-room scheduling at Centre Antoine Lacassagne by predicting the real duration of a surgery from only the data known at the moment it is scheduled: procedure, surgeon, specialty, room, anesthesia type, and the planned duration entered by the team. The project runs under the RNIPH / CNIL MR-004 compliance framework for health data.
The trap: data leakage
The hospital's intra-operative phase timestamps (induction, incision…) only exist once the operation has already started. Including them as features would produce a model that looks brilliant during testing but is useless in production, since none of that data is available at scheduling time. I deliberately excluded these fields from the feature set, and wrote a dedicated unit test that locks this invariant so it can't silently regress.
A model is only useful if it beats the humans
Rather than reporting a raw accuracy score, I compared the model systematically against the hospital's existing planned-duration baseline — the estimate already entered by the scheduling team — on the same test split. On the available demonstration sample (10 interventions), the model does not yet beat the human baseline (MAE 47.5 min vs. 43.0 min for the baseline). The pipeline surfaces this as an explicit deployable / not-deployable verdict rather than hiding it behind a headline metric.
Validating at scale before the data arrives
To validate the approach beyond a 10-row demo, I built a synthetic dataset of 2,500 interventions across a long tail of 227 procedures, with injected missing and corrupted rows. This stress test surfaced a sparse/dense matrix incompatibility in HistGradientBoostingRegressor that was invisible on the small demo sample — fixed before delivery. On this synthetic data, the model selected by cross-validation improves on the baseline by 6.5 minutes of MAE (19.1 vs. 25.6). This result validates the engineering, not the real-world numbers — it doesn't prejudge how the model will perform once real hospital data is available.
Engineering
The pipeline accepts multiple input formats (xlsx, csv, parquet), groups rare categorical values, and tolerates categories unseen at training time. Model selection runs by cross-validation across Ridge, Random Forest and Gradient Boosting. The whole thing is covered by 26 pytest unit tests, validated with mutation testing: 6 deliberately injected regressions, each caught by the test designed to cover it.
Status & what's next
The script and its test suite were delivered as agreed. The hospital-side collaboration — and with it, access to real (non-synthetic) surgery data — has since been postponed. The pipeline is ready to be re-evaluated on real data whenever the collaboration resumes.