Validation¶
A class for validating model predictions against experimental data.
- class ionworkspipeline.Validation(objectives: dict[str, CurrentDriven], summary_stats: list[Cost] | None = None)¶
A pipeline element that validates a model.
Parameters¶
- objectivesdict[str, CurrentDriven]
The objectives to validate.
- summary_statslist[Cost] | None, default=None
The summary statistics to calculate. Should be a list of ionworkspipeline.Cost objects. If None, the default summary statistics will be used, which are RMSE, MAE, and Max.
Extends:
ionworkspipeline.pipeline.PipelineElement
- export_report(filename='validation_report', include_plotlyjs: str | bool = 'cdn', plots: list[str] | None = None, plot_kwargs: dict | None = None)¶
Export a report of the validation results.
Parameters¶
- filenamestr
The name of the folder where the report will be saved. The main report will be named index.html inside this folder.
- include_plotlyjsstr | bool, default=’cdn’
Whether to include the plotly.js library in the report. Default is ‘cdn’, which loads the library from the cdn. This reduces file size, but requires an internet connection. See plotly documentation for more information: https://plotly.com/python-api-reference/generated/plotly.io.to_html.html
- plotslist[str] | None, default=None
The plots to include in the report. If None, model data and error plots will be included. Valid plots are:
- “model data”
Plots model and data voltage vs time.
- “error”
Plots error, model voltage - data voltage in mV vs time.
- “log error”
Plots log error, log10(abs(model voltage - data voltage)) vs time.
- “cumulative rmse”
Plots cumulative RMSE vs time.
- “error moving average”
Plots the moving average of the error vs time, with a window of 5 points.
- plot_kwargsdict | None, default=None
- Additional keyword arguments for plot creation:
- window_lengthint, default=5
The window length for the moving average in the error moving average plot.
- run(parameter_values: dict[str, Any] | ParameterValues)¶
Run the validation.
Parameters¶
- parameter_valuesdict[str, float]
The parameter values to use for the validation. This should contain all the parameters needed to run the model.
Returns¶
- validation_resultsdict[str, dict[str, float]]
A dictionary of validation results. The keys are the names of the objectives, and the values are dictionaries of validation results. The validation results are dictionaries with the following keys:
- “log(Error [V])”
The log of the absolute error.
- “Model voltage [V]”
The model voltage.
- “Processed data voltage [V]”
The processed data voltage.
- “Error [mV]”
The error in mV.
- summary_statsdict[str, list[dict[str, float]]]
A dictionary of summary statistics. The keys are the names of the objectives, and the values are lists of dictionaries. Each dictionary contains the name of the summary statistic and the value of the summary statistic.