Parameters#

See also

Constraints documents the LinearConstraint system and the Parameters.get_constraints() hook used to declare adding-up relationships between parameters.

This class is the base class for all parameter classes. It contains the common methods for all parameter classes.

Constructor#

Parameters([parameters, hyperparameters, ...])

A class for handling parameters for the MacroStat model.

Initialization and Loading#

Parameters.from_json(file_path, *args, **kwargs)

Initialize the parameters from a JSON file.

Parameters.from_excel(file_path, *args, **kwargs)

Initialize the parameters from an Excel file.

Parameters.from_csv(file_path, *args, **kwargs)

Initialize the parameters from a CSV file.

Serialization / IO#

Parameters.to_json(file_path, *args, **kwargs)

Convert the parameters to a JSON file.

Parameters.to_excel(file_path, *args, **kwargs)

Convert the parameters to an Excel file.

Parameters.to_csv(file_path[, sphinx_math])

Convert the parameters to a CSV file.

Parameter Management#

Parameters.set_bound(key, value)

Set the bounds for a single parameter

Parameters.set_notation(key, value)

Set the notation for a single parameter.

Parameters.set_unit(key, value)

Set the unit for a single parameter.

Parameters.verify_bounds()

Verify that the bounds are valid.

Parameters.verify_parameters()

Verify that the parameters are within the bounds.

Constraints#

Parameters.get_constraints()

Return parameter constraints for this model.

Parameters.verify_constraints()

Verify that declared constraints are well-formed.

Parameters.enforce_constraints()

Enforce all constraints by adjusting derived parameter values.

Parameters.get_free_param_names()

Return scalar parameter names excluding derived (constrained) ones.

Notes#

The Parameters class is designed to handle both model parameters and hyperparameters in a structured way. It provides methods for loading parameters from various file formats (JSON, Excel, CSV) and includes validation to ensure parameters are within specified bounds.

Example#

A typical workflow for parameters might look like:

>>> params = Parameters()
>>> params['alpha'] = 0.5
>>> params.to_json('parameters.json')