fit.helpers¶
Helper functions for fitting.
filtered_fit_experiments
¶
filtered_fit_experiments(
experiment_classes,
metadata_filters,
base_path,
data_path,
kind=TRAINING,
)
Create fit experiments from the fit mappings which pass all filters.
Every filter is called with the key of a fit mapping and the FitMapping; a
mapping is used if all filters accept it. The fit experiments use the weights
of the mappings (use_mapping_weights=True).
The kind classifies the selected data: the training data of a fit, the
validation data it is evaluated on, or the outliers which are not used. The
selection and its classification happen here, the fit mappings of the
simulation experiments only describe the curves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment_classes
|
list[type[SimulationExperiment]]
|
simulation experiment classes to filter. |
required |
metadata_filters
|
MappingFilter | Iterable[MappingFilter]
|
a single filter or an iterable of filters. |
required |
base_path
|
Path
|
base path of the simulation experiments. |
required |
data_path
|
Path
|
path of the datasets of the simulation experiments. |
required |
kind
|
MappingKind
|
what a fit does with the selected mappings. |
TRAINING
|
Returns:
| Type | Description |
|---|---|
dict[str, list[FitExperiment]]
|
Tuple of the fit experiments by experiment id and a DataFrame with the |
DataFrame
|
metadata of the accepted mappings. |
f_fitexp
¶
f_fitexp(
experiment_classes,
metadata_filters,
base_path,
data_path,
print_info=True,
kind=TRAINING,
)
Get the filtered fit experiments and print the metadata of the mappings.
See filtered_fit_experiments, this only drops the metadata DataFrame.
mapping_kinds_info
¶
Summarize how the fit mappings of a metadata table are used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
metadata table of |
required |
Returns:
| Type | Description |
|---|---|
str
|
One line with the number of mappings per |
filter_keys
¶
Create a filter which accepts the fit mappings with the given keys.
This selects the data of a fit by name, e.g., the curves which are kept out of the fit as validation data or dropped as outliers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Iterable[str]
|
keys of the fit mappings to accept. |
required |
Returns:
| Type | Description |
|---|---|
MappingFilter
|
Filter for |
filter_not_keys
¶
Create a filter which rejects the fit mappings with the given keys.
This is the complement of filter_keys, i.e., the data which stays in the
fit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
Iterable[str]
|
keys of the fit mappings to reject. |
required |
Returns:
| Type | Description |
|---|---|
MappingFilter
|
Filter for |
fit_experiments_by_kind
¶
fit_experiments_by_kind(
experiment_classes,
base_path,
data_path,
filters_by_kind,
print_info=True,
)
Select the data of a fit and classify it in one step.
Every kind gets its own filters, so the data of a fit is split into the training data, the validation data it is evaluated on and the outliers which are not used. One overview of all selected mappings is printed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment_classes
|
list[type[SimulationExperiment]]
|
simulation experiment classes to filter. |
required |
base_path
|
Path
|
base path of the simulation experiments. |
required |
data_path
|
Path
|
path of the datasets of the simulation experiments. |
required |
filters_by_kind
|
dict[MappingKind, MappingFilter | Iterable[MappingFilter]]
|
filters of every kind, see |
required |
print_info
|
bool
|
print the overview of the selected data. |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, list[FitExperiment]]
|
The fit experiments of all kinds by experiment id. |
merge_fit_experiments
¶
Combine the fit experiments of several selections.
A fit is built from the selections of its kinds, e.g., its training data and its validation data, which are combined here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fit_experiments
|
dict[str, list[FitExperiment]]
|
fit experiments by experiment id. |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, list[FitExperiment]]
|
The fit experiments of all selections by experiment id. |