Result

class glotaran.project.result.Result(number_of_function_evaluations: int, success: bool, termination_reason: str, glotaran_version: str, free_parameter_labels: list[str], scheme: Scheme, initial_parameters: Parameters, optimized_parameters: Parameters, parameter_history: ParameterHistory, optimization_history: OptimizationHistory, data: Mapping[str, xr.Dataset], additional_penalty: list[np.ndarray] | None = None, cost: ArrayLike | None = None, chi_square: float | None = None, covariance_matrix: ArrayLike | None = None, degrees_of_freedom: int | None = None, number_of_clps: int | None = None, jacobian: ArrayLike | list | None = None, number_of_residuals: int | None = None, number_of_jacobian_evaluations: int | None = None, number_of_free_parameters: int | None = None, optimality: float | None = None, reduced_chi_square: float | None = None, root_mean_square_error: float | None = None)[source]

Bases: object

The result of a global analysis.

Attributes Summary

additional_penalty

A vector with the value for each additional penalty, or None

chi_square

The chi-square of the optimization.

cost

The final cost.

covariance_matrix

Covariance matrix.

degrees_of_freedom

Degrees of freedom in optimization N - N_{vars} - N_{clps}.

jacobian

Modified Jacobian matrix at the solution

model

Return the model used to fit result.

number_of_clps

Number of conditionally linear parameters N_{clps}.

number_of_data_points

Return the number of values in the residual vector N.

number_of_free_parameters

Number of free parameters in optimization N_{vars}

number_of_jacobian_evaluations

The number of jacobian evaluations.

number_of_parameters

Return the number of free parameters in optimization N_{vars}.

number_of_residuals

Number of values in the residual vector N.

optimality

reduced_chi_square

The reduced chi-square of the optimization.

root_mean_square_error

The root mean square error the optimization.

source_path

number_of_function_evaluations

The number of function evaluations.

success

Indicates if the optimization was successful.

termination_reason

The reason (message when) the optimizer terminated

glotaran_version

The glotaran version used to create the result.

free_parameter_labels

List of labels of the free parameters used in optimization.

scheme

initial_parameters

optimized_parameters

parameter_history

The parameter history.

optimization_history

The optimization history.

data

The resulting data as a dictionary of xarray.Dataset.

Methods Summary

create_clp_guide_dataset

Create dataset for clp guidance.

get_scheme

Return a new scheme from the Result object with optimized parameters.

loader

Create a Result instance from the specs defined in a file.

markdown

Format the model as a markdown text.

recreate

Recrate a result from the initial parameters.

save

Save the result to given folder.

verify

Verify a result.

Methods Documentation

additional_penalty: list[np.ndarray] | None = None

A vector with the value for each additional penalty, or None

chi_square: float | None = None

The chi-square of the optimization.

\chi^2 = \sum_i^N [{Residual}_i]^2.

cost: ArrayLike | None = None

The final cost.

covariance_matrix: ArrayLike | None = None

Covariance matrix.

The rows and columns are corresponding to free_parameter_labels.

create_clp_guide_dataset(clp_label: str, dataset_name: str) Dataset[source]

Create dataset for clp guidance.

Parameters:
  • clp_label (str) – Label of the clp to guide.

  • dataset_name (str) – Name of dataset to extract the guide from.

Returns:

DataArray containing the clp guide, with clp_label dimension replaced by the model dimensions first value.

Return type:

xr.Dataset

Raises:

Examples

Extracting the clp guide from an optimization result object.

from glotaran.io import save_dataset

clp_guide = result.create_clp_guide_dataset("species_1", "dataset_1")
save_dataset(clp_guide, "clp_guide__result_dataset_1__species_1.nc")
data: Mapping[str, xr.Dataset]

The resulting data as a dictionary of xarray.Dataset.

Notes

The actual content of the data depends on the actual model and can be found in the documentation for the model.

degrees_of_freedom: int | None = None

Degrees of freedom in optimization N - N_{vars} - N_{clps}.

free_parameter_labels: list[str]

List of labels of the free parameters used in optimization.

get_scheme() Scheme[source]

Return a new scheme from the Result object with optimized parameters.

Returns:

A new scheme with the parameters set to the optimized values. For the dataset weights the (precomputed) weights from the original scheme are used.

Return type:

Scheme

glotaran_version: str

The glotaran version used to create the result.

initial_parameters: Parameters
jacobian: ArrayLike | list | None = None

Modified Jacobian matrix at the solution

See also: scipy.optimize.least_squares()

loader(format_name: str | None = None, **kwargs: Any) Result

Create a Result instance from the specs defined in a file.

Parameters:
  • result_path (StrOrPath) – Path containing the result data.

  • format_name (str | None) – Format the result is in, if not provided and it is a file it will be inferred from the file extension.

  • **kwargs (Any) – Additional keyword arguments passes to the load_result implementation of the project io plugin.

Returns:

Result instance created from the saved format.

Return type:

Result

markdown(with_model: bool = True, *, base_heading_level: int = 1, wrap_model_in_details: bool = False) MarkdownStr[source]

Format the model as a markdown text.

Parameters:
  • with_model (bool) – If True, the model will be printed with initial and optimized parameters filled in.

  • base_heading_level (int) – The level of the base heading.

  • wrap_model_in_details (bool) – Wraps model into details tag. Defaults to False

Returns:

MarkdownStr – The scheme as markdown string.

Return type:

str

property model: Model

Return the model used to fit result.

Returns:

The model instance.

Return type:

Model

number_of_clps: int | None = None

Number of conditionally linear parameters N_{clps}.

property number_of_data_points: int | None

Return the number of values in the residual vector N.

Deprecated since it returned the wrong value.

Returns:

Number of values in the residual vector N.

Return type:

int | None

number_of_free_parameters: int | None = None

Number of free parameters in optimization N_{vars}

number_of_function_evaluations: int

The number of function evaluations.

number_of_jacobian_evaluations: int | None = None

The number of jacobian evaluations.

property number_of_parameters: int | None

Return the number of free parameters in optimization N_{vars}.

Returns:

Number of free parameters in optimization N_{vars}.

Return type:

int | None

number_of_residuals: int | None = None

Number of values in the residual vector N.

optimality: float | None = None
optimization_history: OptimizationHistory

The optimization history.

optimized_parameters: Parameters
parameter_history: ParameterHistory

The parameter history.

recreate() Result[source]

Recrate a result from the initial parameters.

Returns:

The recreated result.

Return type:

Result

reduced_chi_square: float | None = None

The reduced chi-square of the optimization.

\chi^2_{red}= {\chi^2} / {(N - N_{vars} - N_{clps})}.

root_mean_square_error: float | None = None

The root mean square error the optimization.

rms = \sqrt{\chi^2_{red}}

save(path: StrOrPath, saving_options: SavingOptions = SavingOptions(data_filter=None, data_format='nc', parameter_format='csv', report=True)) list[str][source]

Save the result to given folder.

Parameters:
  • path (StrOrPath) – The path to the folder in which to save the result.

  • saving_options (SavingOptions) – Options for the saved result.

Returns:

Paths to all the saved files.

Return type:

list[str]

scheme: Scheme
source_path: StrOrPath = 'result.yml'
success: bool

Indicates if the optimization was successful.

termination_reason: str

The reason (message when) the optimizer terminated

verify() bool[source]

Verify a result.

Returns:

Weather the recreated result is equal to this result.

Return type:

bool