Result

class ionworkspipeline.Result(parameter_values: dict, optimizer_result: OptimizerResult | SamplerResult, samples: ndarray | None = None, costs: ndarray | None = None, callbacks: dict | None = None, callback_results: dict | None = None, children: list[Result] | None = None, initial_guess: dict | None = None, job_id: int | None = None)

A class to store the results of a ionworkspipeline.DataFit.

Parameters

parameter_valuesdict

The final values of the optimized parameters.

optimizer_resultionworkspipeline.OptimizerResult or ionworkspipeline.SamplerResult

The result object returned by the SciPy optimizer.

callbacksdict

The callbacks used during optimization.

callback_resultsdict

The results collected by callbacks during optimization.

childrendict, optional

Results from multistarted parameter estimation if applicable.

Attributes

parameter_valuesdict

The final values of the optimized parameters.

optimizer_resultionworkspipeline.OptimizerResult or ionworkspipeline.SamplerResult

The result object in the format returned by the SciPy optimizer.

callbacksdict

The callbacks used during optimization.

callback_resultsdict

The results collected by callbacks during optimization, formatted as follows:

{
    "callback_name": {
        "data": ...,
        "options": ...,
        "initial_results": {
            "inputs": ...,
            "outputs": ...,
        },
        "fit_results": {
            "inputs": ...,
            "outputs": ...,
        },
    },
    ...
}
childrendict

Results from sub-fits if this was part of a composite fit.

initial_guessdict

The initial guess for the parameters.

Notes

The specific attributes available in optimizer_result may vary depending on the optimization method used. Refer to SciPy’s documentation for a complete list of possible attributes.

Extends: builtins.dict

best_results(num_results: int | integer | None = None) list[Result]

Returns the best results from the children in ascending order of cost.

Parameters

num_resultsint or np.integer, optional

The number of best results to return. If None, all children are returned.

Returns

list[Result]

The best results from the children in ascending order of cost.

get_fit_results()

Get the results of the fit.

Returns

dict

Dictionary containing fit results for each objective.

plot_fit_results()

Plot the results of the fit by calling the plot_fit_results method of each internal callback in each objective. Any user-defined callbacks should be called manually instead of using this method.

Returns

dict

Dictionary containing figure and axes objects for each objective.

class ionworkspipeline.OptimizerResult(x=None)

Result of an optimization. Inherits from scipy.optimize.OptimizeResult.

This class represents the result of running an optimizer. It contains the optimal parameter values found and other optimization-related information like function evaluations, success status etc.

Parameters

xarray_like, optional

The solution of the optimization. Default is None.

Extends: scipy.optimize._optimize.OptimizeResult

class ionworkspipeline.SamplerResult(samples=None, costs=None)

Result of a sampling procedure. Inherits from scipy.optimize.OptimizeResult.

This class represents the result of running a sampler. It contains the samples drawn from the parameter space and their associated costs/objective function values.

Parameters

samplesarray_like, optional

The samples drawn from the parameter space. Default is None.

costsarray_like, optional

The cost/objective function values for each sample. Default is None.

Extends: scipy.optimize._optimize.OptimizeResult

property log_pdfs

Converts costs to log probability density values.

Returns

array_like

The negative log of the costs, representing log probability densities.

property x

Returns the sample with the lowest cost.

Since we are minimizing the cost function, this represents the best parameter values found during sampling.

Returns

array_like

The sample with the minimum cost value.

ionworkspipeline.result.combine(children: list[Result]) Result

Combine a list of results into a single result.

Parameters

childrenlist[Result]

The list of results to combine.

Returns

Result

A new Result object containing the combined children of both results, sorted by their minimum costs. The properties of the returned Result are taken from the child with the smallest cost.