Skip to content

Refactor of Incoming admission predictor API

Choose a tag to compare

@zmek zmek released this 19 Apr 07:59
· 9 commits to main since this release
68f5611

Incoming admission predictor API

Highlights

This release refactors yet-to-arrive (incoming) admission predictors so prediction is explicit at call time and a single fitted model can be reused for different horizons and targets without refitting.

Incoming admission predictors (DirectAdmissionPredictor, ParametricIncomingAdmissionPredictor, EmpiricalIncomingAdmissionPredictor)

  • fit() no longer owns the prediction window. It fits a full 24-hour arrival profile; prediction_window / prediction_times on fit() are deprecated (with DeprecationWarning) and retained only as a temporary fallback.
  • predict() and predict_mean() now take the prediction window and prediction time as explicit keyword arguments, and (where applicable) filter_keys for choosing one or more hospital services (model weights keys) in predict(), or filter_key for choosing the single service used by predict_mean()
  • Passing a nested prediction_context dict is deprecated; callers should migrate to the flat arguments. Deprecated paths remain for compatibility but may be removed in a future major version.
  • Time handling is centralised: _resolve_prediction_window, snapping to yta_time_interval boundaries (with a UserWarning when times are adjusted), and helpers to normalise prediction instants. The old find_nearest_previous_prediction_time helper is removed.

Integration points

Call sites are updated so the new API is threaded through aggregate (e.g. survival-curve probability paths), predict.emergency_demand, and predict.service (including safe mean prediction). Obsolete window-mismatch checks tied to the old fit()-time window are dropped. Training utilities (train.incoming_admission_predictor) no longer forward the deprecated fit() window kwargs by default.

Breaking changes

  • Serialised models produced by older versions are not supported with this predictor stack; retrain or rebuild for the new fitting and prediction contract.
  • Any custom code that relied on find_nearest_previous_prediction_time or on fixing the prediction window only at fit() must be updated to pass prediction_window (and related arguments) on predict() / predict_mean().

Upgrade path

  1. Refit incoming admission models if you load pickled or otherwise stored models from before this change.
  2. Replace fit(..., prediction_window=...) with fit() (or rely on deprecation only briefly) and pass prediction_window= on each predict() / predict_mean().
  3. Replace dict-style prediction_context with prediction_time, prediction_window, and filter_keys / filter_key as appropriate.