Skip to content

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

reference_set

First parameter set, the reference the others are compared against.

opt_result_required property

opt_result_required

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

from_optimization_result(
    problem, opt_result, size=1, with_model=True, **kwargs
)

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 FitReport.

{}

Returns:

Type Description
FitReport

The report of the fit.

mapping_title

mapping_title(k)

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.

color

color(pset)

Get the color of a parameter set.

x

x(pset)

Get the values of a set in the parameter order of the problem.

metrics

metrics(pset)

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 sbmlsim.fit.metrics.

metrics_df

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.

metrics_mappings_df

metrics_mappings_df()

Get the metrics of every fit mapping and parameter set.

datapoints_df

datapoints_df()

Get the data points with their predictions for every parameter set.

residual_data

residual_data(pset)

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(
    output_dir,
    name=None,
    show_report=False,
    mpl_parameters=None,
)

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

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.

html_report

html_report(path)

Create the HTML report of the fit.

plot_fit

plot_fit(output_dir)

Plot the data and the simulation of every parameter set per mapping.

plot_fit_residual

plot_fit_residual(output_dir)

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_datapoint_scatter(path)

Plot the predicted against the measured data points, per set.

plot_residual_scatter

plot_residual_scatter(path)

Plot the relative residuals against the data, per set.

plot_cost_bar

plot_cost_bar(path)

Plot the cost and the weight of every curve, per set.

plot_residual_boxplot

plot_residual_boxplot(path)

Plot the distribution of the squared weighted residuals per curve.

plot_cost_scatter

plot_cost_scatter(path)

Plot the cost of every curve against the cost of the reference set.

plot_waterfall

plot_waterfall(path)

Create waterfall plot for the fit results.

Plots the optimization runs sorted by cost.

plot_traces

plot_traces(path)

Plot optimization traces.

Optimization time course of costs.