aimz.ImpactModel.sample_posterior_predictive#
- ImpactModel.sample_posterior_predictive(X, *, intervention=None, rng_key=None, return_sites=None, batch_size=None, output_dir=None, progress=True, **kwargs)[source]#
Draw samples from the posterior predictive distribution.
This method is a convenience alias for
predict(), within_sampleautomatically set toTrue.- Parameters:
X (ArrayLike | ArrayLoader) – Input data. If array-like, the leading axis is the sample axis. Alternatively, a data loader that holds all array-like objects and handles batching internally.
intervention (dict | None) – A dictionary mapping sample sites to their corresponding intervention values. Interventions enable counterfactual analysis by modifying the specified sample sites during prediction (posterior predictive sampling).
rng_key (Array | None) – A pseudo-random number generator key. By default, an internal key is used and split as needed.
return_sites (str | Iterable[str] | None) – Names of variables (sites) to return. If
None, samplesparam_outputand deterministic sites.batch_size (int | None) – The batch size for data loading during posterior predictive sampling. It also determines the chunk size used to store the samples. If
None, it is determined automatically based on the input data and number of samples. Ignored ifXis a data loader, in which case the data loader is expected to handle batching internally.output_dir (str | Path | None) – The directory where the outputs will be saved. If the specified directory does not exist, it will be created automatically. If
None, a default temporary directory will be created. A timestamped subdirectory will be generated within this directory to store the outputs. Outputs are saved in the Zarr format.progress (bool) – Whether to display a progress bar.
**kwargs (object) – Additional arguments passed to the model.
- Returns:
Posterior predictive samples. Posterior samples are included if available.
- Raises:
TypeError – If
param_outputis passed as an argument.- Return type:
xr.DataTree
See also