aspire.history#
Classes#
Base class for storing history of a sampler. |
|
Base class for storing history of a sampler. |
|
Base class for storing history of a sampler. |
Module Contents#
- class aspire.history.FlowHistory[source]#
Bases:
HistoryBase class for storing history of a sampler.
- class aspire.history.SMCHistory[source]#
Bases:
HistoryBase class for storing history of a sampler.
- sample_history: list[aspire.samples.SMCSamples] = [][source]#
- save(h5_file, path='smc_history')[source]#
Save the history to an HDF5 file.
The sample history is saved as a separate group under the main history group, with one subgroup per iteration. The number of iterations is stored in the main history group to allow for loading the sample history correctly.
- Parameters:
h5_file (
h5py.File) – The open HDF5 file to save to.path (
str, optional) – The path within the HDF5 file to save the history. Default is “smc_history”.
- classmethod load(h5_file, path='smc_history')[source]#
Load the history from an HDF5 file.
- Parameters:
h5_file (
h5py.File) – The open HDF5 file to load from.path (
str, optional) – The path within the HDF5 file to load the history from. Default is “smc_history”.
- Returns:
The loaded history instance.
- Return type:
- plot(fig=None)[source]#
- Parameters:
fig (matplotlib.figure.Figure | None)
- Return type:
matplotlib.figure.Figure
- plot_sample_history(n_samples=None, parameters=None, ax=None, cmap='viridis', scatter_kwargs=None, x_axis='log_p_t', iterations=None)[source]#
Plot the history of samples in the SMC sampler.
- Parameters:
n_samples (
int, optional) – Number of samples to plot from each iteration. If None, plot all samples.parameters (
listofstr, optional) – List of parameter names to plot. If None, plot all parameters.ax (
matplotlib.axes.Axes, optional) – Axes to plot on. If None, a new figure and axes will be created.cmap (
str, optional) – Colormap to use for plotting the samples. Default is “viridis”.scatter_kwargs (
dict, optional) – Keyword arguments to pass to the scatter function. If None, no additional arguments will be passedx_axis (
str, optional) – Quantity to use for the x-axis. Supported values are"log_p_t"and"log_likelihood". Falls back to iteration index if required fields are missing.iterations (list[int] | None)
- Return type:
matplotlib.figure.Figure | None
- plot_quantile_bands(parameters=None, quantile_interval=(0.1, 0.9), ax=None, line_kwargs=None, band_kwargs=None)[source]#
Plot per-parameter quantile bands vs iteration.
- Parameters:
parameters (
list[str] | None, optional) – Parameters to plot. If None, all parameters are used.quantile_interval (
tuple[float,float], optional) – Lower/upper quantiles to plot as a band.ax (
matplotlib.axes.Axes | list[matplotlib.axes.Axes] | None, optional) – Axes to draw on. If None, creates a new figure.line_kwargs (
dict | None, optional) – Keyword arguments for the median line.band_kwargs (
dict | None, optional) – Keyword arguments for the quantile band fill.
- Return type:
matplotlib.figure.Figure | None