reorder_to_model_coords#

pymc_marketing.pytensor_utils.reorder_to_model_coords(posterior, model_coords)[source]#

Return posterior with each labeled non-sample dim in the model’s order.

A graph reads draws and data by position in the model’s coord order, so the model is the reference layout. ConditionedModel applies this to every posterior it receives, and Incrementality to the channel data its baseline is evaluated on. A dim whose labels differ from the model’s in value or length – a refit window, a thinned posterior – is left as given, for whatever reads it to validate. chain and draw are never reordered.

Parameters:
  • posterior (Dataset) – The draws, or any dataset over the model’s dims, to reorder.

  • model_coords (Mapping[str, Any]) – The coordinates of the model, such as pm.Model.coords.

Return type:

xr.Dataset

Returns:

posterior in the model’s label order on every dim whose labels equal the model’s (unique) labels as a set; other dims keep their order.