fit.parameters¶
Parameter sets, the artifact which connects a fit to its report.
A parameter fit stores its results as ParameterSets: named sets of parameter
values with their units. A report is created from the definition of the
optimization problem, the settings of the fit and one or more of these sets, so
that reporting is separate from optimizing and several sets can be compared in
a single report.
ParameterSet
dataclass
¶
A named set of parameter values.
Attributes:
| Name | Type | Description |
|---|---|---|
sid |
str
|
identifier of the set, used as its label in a report. |
values |
dict[str, float]
|
value of every parameter by parameter id. |
units |
dict[str, str | None]
|
unit of every parameter by parameter id, the model unit if |
cost |
float | None
|
cost of the set, if it comes from an optimization. |
provenance |
str | None
|
where the set comes from, e.g. the id of an optimization. |
x
¶
Get the values as a vector in the order of the given parameter ids.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pids
|
Sequence[str]
|
parameter ids of the optimization problem. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Vector of the values. |
Raises:
| Type | Description |
|---|---|
KeyError
|
if the set does not contain one of the parameters. |
from_fit_parameters
staticmethod
¶
Create a parameter set from the parameters of a problem and a vector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
Iterable[FitParameter]
|
fit parameters, they provide the ids and the units. |
required |
x
|
Sequence[float] | ndarray
|
values in the order of the parameters. |
required |
sid
|
str
|
identifier of the set. |
required |
cost
|
float | None
|
cost of the set. |
None
|
provenance
|
str | None
|
where the set comes from. |
None
|
Returns:
| Type | Description |
|---|---|
ParameterSet
|
The parameter set. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the number of values does not match the parameters. |
from_model
staticmethod
¶
Create the parameter set of the initial values of the model.
ParameterSets
dataclass
¶
One or more named parameter sets.
This is what a fit writes and a report reads; the sets of a report are compared with each other, e.g., the fitted parameters against the initial values of the model.
of
staticmethod
¶
Accept a single set, an iterable of sets or ParameterSets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameter_sets
|
ParameterSets | Iterable[ParameterSet] | ParameterSet
|
the sets in any of the supported forms. |
required |
Returns:
| Type | Description |
|---|---|
ParameterSets
|
The sets as |
Raises:
| Type | Description |
|---|---|
ValueError
|
if no set is given. |
to_json
¶
Store the sets as JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | None
|
file to write, the JSON string is returned if it is |
None
|
Returns:
| Type | Description |
|---|---|
str | Path
|
The path or the JSON string. |
from_json
staticmethod
¶
Load the sets from a JSON file or string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_info
|
str | Path
|
path of the file or the JSON string. |
required |
Returns:
| Type | Description |
|---|---|
ParameterSets
|
The parameter sets. |