fit.report¶
Report of a parameter fit.
Reporting is separate from optimizing: a FitReport is created from the
definition of an OptimizationProblem, the FitSettings of the fit and one or
more ParameterSets. It does not need an optimization to have been run in the
same session, and several parameter sets can be compared in a single report,
e.g., the fitted parameters against the initial values of the model or the
results of two fits against each other.
The plots which describe an optimization run rather than a parameter set, i.e.,
the traces of the optimizers and the waterfall plot, are only created when the
OptimizationResult of the run is passed as well.
FitReport
¶
FitReport(
problem,
settings,
parameter_sets,
opt_result=None,
show_titles=True,
image_format="svg",
)
Report of a fit for one or more parameter sets.
Creates the figures, the text report and the HTML report of a fit.
Construct the report.
The problem is initialized with the settings, which resolves the data of the fit mappings. A problem which is already initialized with the same settings is left alone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
OptimizationProblem
|
definition of the optimization problem. |
required |
settings
|
FitSettings
|
settings the parameter sets were fitted with. |
required |
parameter_sets
|
ParameterSets | list[ParameterSet] | ParameterSet
|
one or more sets of parameters to report. The first set is the reference the others are compared against. |
required |
opt_result
|
OptimizationResult | None
|
result of an optimization, adds the traces, the waterfall plot and the table of the runs. |
None
|
show_titles
|
bool
|
add titles to the panels. |
True
|
image_format
|
str
|
format of the figures. |
'svg'
|
reference_set
property
¶
First parameter set, the reference the others are compared against.
opt_result_required
property
¶
Result of the optimization, required for the plots of the runs.
Raises:
| Type | Description |
|---|---|
ValueError
|
if the report was created without a result. |
from_optimization_result
staticmethod
¶
Create the report of an optimization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
OptimizationProblem
|
definition of the optimization problem. |
required |
opt_result
|
OptimizationResult
|
result of the optimization, it carries the settings. |
required |
size
|
int
|
number of fitted parameter sets to report, the best first. |
1
|
with_model
|
bool
|
report the initial values of the model as the reference set, so that the plots compare the fit against them. |
True
|
kwargs
|
Any
|
additional arguments of |
{}
|
Returns:
| Type | Description |
|---|---|
FitReport
|
The report of the fit. |
mapping_title
¶
Get the title of the plots of a fit mapping.
Data which is not fitted is marked, so that it is visible in the figures which curves the parameters were fitted on.
metrics
¶
Get the metrics of a parameter set on the problem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pset
|
ParameterSet
|
parameter set of the report. |
required |
Returns:
| Type | Description |
|---|---|
FitMetrics
|
The metrics of the set, see |
metrics_df
¶
Get the metrics of every parameter set, per kind of fit mapping.
A fit is evaluated on its training and on its validation data, so every parameter set has a row per kind.
residual_data
¶
Get the complete residual data of the mappings for a parameter set.
Every evaluation simulates all fit mappings, so the results are cached for the plots and tables which use the same set.
create
¶
Create the complete report.
Writes the figures, the text report, the parameter sets and the HTML
report into output_dir / name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
Path
|
base directory of the reports. |
required |
name
|
str | None
|
name of this report, the id of the optimization by default. |
None
|
show_report
|
bool
|
open the HTML report in a web browser. |
False
|
mpl_parameters
|
dict[str, Any] | None
|
additional matplotlib rc parameters of the figures. |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path of the directory the report was written to. |
parameters_report
¶
Get the report of the parameter sets.
Reports the values of every set and the parameters which ended up close to one of their bounds.
plot_fit
¶
Plot the data and the simulation of every parameter set per mapping.
plot_fit_residual
¶
Plot data, prediction and residuals of every mapping.
The upper panels show the data, the interpolated prediction and the residuals, the lower panels the squared weighted residuals; the right panels are logarithmic.
plot_datapoint_scatter
¶
Plot the predicted against the measured data points, per set.
plot_residual_scatter
¶
Plot the relative residuals against the data, per set.
plot_residual_boxplot
¶
Plot the distribution of the squared weighted residuals per curve.
plot_cost_scatter
¶
Plot the cost of every curve against the cost of the reference set.
plot_waterfall
¶
Create waterfall plot for the fit results.
Plots the optimization runs sorted by cost.