Results¶
Typed result objects returned by pipeline elements. BaseResults is the
shared base for every result; the DataFit family (ParameterEstimatorResult
and its subtypes) carries fitted parameters plus cost history, and
ValidationResult / PassthroughResult cover validation and plain
parameter-values returns.
Typed result objects a pipeline element returns.
BaseResults is the shared base and carries the fitted
parameter_values; the subclasses add what their kind of element produces —
an optimizer’s cost history, a sampler’s chains, a validation’s summary stats.
Every result round-trips through BaseResults.to_config() and
from_config(), which dispatches on the stored type.
- class ionworks.pipeline.results.BaseResults(parameter_values: dict | None = None, **_)[source]¶
Bases:
objectBase class for typed result objects returned by pipeline elements.
Subclasses set a unique
typeClassVar and overrideto_config()to expose their payload fields.- attach_source(fetcher_map: dict) None[source]¶
Register zero-arg fetchers for the lazy fields.
A fetcher runs when its field is first read and its answer is cached. An empty answer is not cached, so a later read retries. It never overrides a value already set directly.
- Parameters:
fetcher_map (dict) – Mapping of lazy field name (one of
"overlay","trace","posterior","series") to a zero-argument callable returning that field’s value.- Raises:
ValueError – If
fetcher_mapcontains a key that isn’t a recognized lazy field.
- set_source(**fetchers) None[source]¶
Keyword-argument alias for
attach_source().- Parameters:
**fetchers – Same as
fetcher_mapinattach_source(), passed as keyword arguments, e.g.set_source(overlay=fetch_overlay).
- explain_no_plots(message: str) None[source]¶
Set what
plot_fit_results()says when no plots are stored.- Parameters:
message (str) – Replaces the default explanation.
- property overlay: dict | None¶
The fit’s model-vs-data plots, keyed by objective name.
Each entry is
{"type": <objective type>, "plots": [...]}, wheretypeis the objective’s discriminator ("EIS","CycleAgeing", …) and each plot carries namedtracesplus axis titles — the shape documented inionworks.pipeline.plots.Used by
plot_fit_results().Noneuntil populated (directly, or lazily via a fetcher registered withattach_source()).
- property trace: list[dict] | None¶
list of
{"best_cost", "cost", "inputs_unscaled"}.Used by
plot_trace().Noneuntil populated (directly, or lazily via a fetcher registered withattach_source()).- Type:
Optimizer trace
- property posterior: dict | None¶
Posterior sampling data, populated directly or lazily via a fetcher.
Noneuntil populated (directly, or lazily via a fetcher registered withattach_source()).
- property series: dict | None¶
Raw model-vs-data time series, keyed by objective then source.
Each entry is
{source: {channel: [values]}}wheresourceis"optimal"or"baseline"and the channels are the objective’s full-resolution data and model traces (e.g."Time [s]","Voltage [V] (data)","Voltage [V] (model)"). Unlikeoverlay(decimated plot data for figures), this is the numeric series to save or analyse.Noneuntil populated (directly, or lazily via a fetcher registered withattach_source()).
- classmethod from_config(config: dict) ionworks.pipeline.BaseResults[source]¶
Instantiate the right
BaseResultssubclass from a config dict.Pops
type, looks up the subclass via the module-level registry, recurses intochildrenso nested results deserialize to the right subclass, and forwards the rest as kwargs.- Parameters:
config (dict) – A result config dict as produced by
to_config().- Returns:
An instance of the registered subclass matching
config["type"].- Return type:
- Raises:
ValueError – If
configdoes not contain a recognizedtypekey.
- plot_fit_results() dict[source]¶
Plot measured-vs-model data for each objective in
overlay.Each objective is drawn by the renderer for its type (
ionworks.pipeline.plots.render()), so a fit’s figures look the same here as they do in the pipeline that produced them.- Returns:
{objective: (fig, axes)}for every objective inoverlaythat has plots. An objective the backend stored no plots for is left out rather than contributing an empty figure.- Return type:
- Raises:
ValueError – If
overlayisNone, or if it yields nothing to draw.ImportError – If matplotlib (the
plotextra) is not installed.
- plot_trace()[source]¶
Plot optimizer convergence from
trace.Draws the best-cost curve plus a per-parameter staircase of
inputs_unscaledacross iterations.- Returns:
(fig, axes)whereaxeshas one subplot for the best-cost curve followed by one subplot per parameter.- Return type:
- Raises:
ValueError – If
traceisNone.ImportError – If matplotlib (the
plotextra) is not installed.
- class ionworks.pipeline.results.ConfidenceIntervalResult(parameter_values: dict | None = None, *, method: str = 'linear', confidence_level: float = 0.95, intervals: dict | None = None, covariance=None, **kwargs)[source]¶
Bases:
BaseResultsPer-parameter confidence interval bounds.
Mirrors
ionworkspipeline.analysis.results.ConfidenceIntervalResult.- property covariance¶
- class ionworks.pipeline.results.EnsembleResult(parameter_values: dict | None = None, *, x=None, method: str | None = None, **kwargs)[source]¶
Bases:
ParameterEstimatorResultDataFit return for ensemble-of-points evaluators (grid search, point estimate, batch point estimate).
- property x¶
- class ionworks.pipeline.results.OptimizationResult(parameter_values: dict | None = None, *, x=None, fun: float | None = None, success: bool | None = None, message: str | None = None, evaluations: int | None = None, iterations: int | None = None, **kwargs)[source]¶
Bases:
ParameterEstimatorResultDataFit return for deterministic optimizers (CMA-ES, Scipy, …).
- property x¶
- class ionworks.pipeline.results.ParameterEstimatorResult(parameter_values: dict | None = None, *, cost: float | None = None, samples=None, costs=None, children: list[ParameterEstimatorResult] | None = None, initial_guess: dict | None = None, job_id: int | None = None, **kwargs)[source]¶
Bases:
BaseResultsDataFit-family result: an optimizer/sampler’s fitted parameters plus the cost history that produced them.
Mirrors
ionworkspipeline.data_fits.results.ParameterEstimatorResult.- property samples¶
- property costs¶
- property children: list[ParameterEstimatorResult]¶
- best_results(num_results: int | None = None) list[ParameterEstimatorResult][source]¶
Return the best
num_resultschildren, assumed ordered ascending by cost.- Parameters:
num_results (int, optional) – Number of children to return. Defaults to all of
children.- Returns:
The first
num_resultsentries ofchildren.- Return type:
- Raises:
ValueError – If
num_resultsexceeds the number of available children.
- class ionworks.pipeline.results.PassthroughResult(parameter_values: dict | None = None, **_)[source]¶
Bases:
BaseResultsWraps elements that return a plain dict / parameter-values mapping.
- class ionworks.pipeline.results.PosteriorResult(parameter_values: dict | None = None, *, chains=None, chains_storage_ref: str | None = None, log_pdfs=None, parameter_names: list[str] | None = None, burnin: int = 0, method: str | None = None, acceptance_rate: float | None = None, r_hat: dict[str, float] | None = None, ess: dict[str, float] | None = None, posterior_summary: dict[str, dict[str, float]] | None = None, **kwargs)[source]¶
Bases:
ParameterEstimatorResultDataFit return for MCMC samplers (e.g. Pints).
- property chains¶
(chain, draw, parameter)samples, orNonewhen unavailable.Populates on access like
overlay/trace/posterior: a fit whose chains were offloaded rebuilds them from theposteriorpayload.to_config()still reports them as offloaded, so recovering here cannot inline them back onto the wire.
- property x¶
Best-cost sample, for parity with scipy’s
OptimizeResult.x.Falls back to the
posteriorpayload when the chains were offloaded.Nonewhen neither can supply samples and costs.
- property log_pdfs¶
- property burnin: int¶
Draws per chain this result was constructed with, and serializes.
Not necessarily the number
marginal()dropped: when the chains were rebuilt from theposteriorpayload, that payload’s ownsample_burninapplies instead. Read a marginal’s length rather than this field to know what was discarded.
- property posterior_summary: dict[str, dict[str, float]] | None¶
Per-parameter
{mean, std, median, q05, q95}, if provided.
- marginal(name: str)[source]¶
Flattened post-burnin samples for parameter
name.- Parameters:
name (str) – Parameter name; must be one of
parameter_names.- Returns:
1-D array of samples for
nameacross all chains, with the firstburnindraws of each chain dropped.- Return type:
numpy.ndarray
- Raises:
ValueError – If neither
chainsnorposteriorcan supply samples.KeyError – If
nameis not inparameter_names.
- credible_interval(name: str, level: float = 0.95) tuple[float, float][source]¶
Equal-tailed credible interval for parameter
nameatlevel.- Parameters:
name (str) – Parameter name; must be one of
parameter_names.level (float, optional) – Central probability mass to cover. Defaults to 0.95.
- Returns:
(lower, upper)quantile bounds of the marginal distribution.- Return type:
- posterior_mean() dict[str, float][source]¶
Mean of each parameter’s post-burnin marginal.
Reads from
posterior_summarywhen it is present, so it still works when the full chains were too large to inline; otherwise computes the mean fromchains.- Returns:
{parameter_name: mean}.- Return type:
dict of str to float
- class ionworks.pipeline.results.RegressionResult(parameter_values: dict | None = None, *, x=None, results=None, **kwargs)[source]¶
Bases:
ParameterEstimatorResultDataFit return for
Regressoroptimizers.- property x¶
- property results¶
- class ionworks.pipeline.results.SensitivityResult(parameter_values: dict | None = None, *, method: str = 'sobol', first_order: dict | None = None, total_order: dict | None = None, first_order_ci: dict | None = None, total_order_ci: dict | None = None, second_order: dict | None = None, second_order_ci: dict | None = None, evaluation_stats: dict | None = None, n_samples: int = 0, log_transformed: bool = False, **kwargs)[source]¶
Bases:
BaseResultsPer-parameter sensitivity indices.
Mirrors
ionworkspipeline.analysis.results.SensitivityResult.
- class ionworks.pipeline.results.ValidationResult(parameter_values: dict | None = None, *, validation_results: dict | None = None, summary_stats: dict | None = None, failed_objectives: dict[str, str] | None = None, **kwargs)[source]¶
Bases:
BaseResultsResult returned by
iw.pipeline.Validation.
- ionworks.pipeline.results.from_config(config: dict) ionworks.pipeline.BaseResults[source]¶
Instantiate the right
BaseResultssubclass from a config dict.Convenience wrapper for
BaseResults.from_config(), mirroringionworkspipeline.results.parse_element_result; see it for the dispatch rules and what an unrecognizedtyperaises.- Parameters:
config (dict) – A result config dict as produced by
BaseResults.to_config().- Returns:
An instance of the registered subclass matching
config["type"].- Return type: