eradiate.testing.regression.RMSETest#
- class eradiate.testing.regression.RMSETest(threshold, *, variable='brf_srf', dim=None)#
Bases:
RegressionTestRoot-mean-square error test.
The test passes iff the root mean squared error (RMSE) of the result data against the reference is lower than or equal to the given threshold.
- Parameters:
threshold (
float) – Test metric threshold.variable (
str, default:"brf_srf") – Tested variable.dim (
str, optional, default:None) – If set, evaluate the metric independently for each value of this dimension. The test then passes iff every slice passes, and the reported metric is that of the worst slice. This is stricter than comparing the flattened arrays in one go, and it is how datasets aggregating several independent measurements (e.g. one per wavelength) must be tested. Tests whose threshold is a false-positive rate rather than an absolute tolerance (e.g.ZTest) correct for the number of slices, so that threshold keeps its meaning; seeevaluate().
- Fields:
- evaluate(result, reference)#
Compare result against reference using this test’s criterion.
- Parameters:
- Returns:
- Raises:
ValueError – If the data is malformed, e.g. if the shapes do not match or if a required data variable is missing. This is a broken comparison, not a failed one: a failed comparison is reported through the returned outcome.
Notes
When dim is set, each slice is evaluated on its own and the per-slice metrics are combined into the single value carried by the outcome. Two hooks control that combination:
_slice_threshold()sets the threshold each slice is evaluated against, and_aggregate_metrics()turns the per-slice metrics back into one comparable with threshold. Their defaults simply take the worst slice, which is what an absolute tolerance such as an RMSE calls for. A test whose threshold is a false-positive rate must override both, otherwise judging N slices at level \(\alpha\) would let the overall false-positive rate grow to \(1 - (1 - \alpha)^N\); seeZTest.
- plot(result, reference, outcome=None)#
Draw the comparison chart: reference and result overlaid, their absolute and relative differences, and the test’s diagnostic panel.
- Parameters:
result (
Dataset) – Simulation result.reference (
Dataset) – Reference data.outcome (
RegressionTestOutcome, optional) – Verdict to annotate the chart with. If unset, the metric is reported as unavailable and no diagnostic panel is drawn — which is what to do when the comparison itself raised.
- Returns:
figure (
Figure)axes (
ndarray) – 2×2 array of Axes.
- plot_diagnostic(ax, **diagnostic_data)#
Draw more technical information about the test metric and decision process on a panel of the comparison chart. The diagnostic plot can help the user debug a failing test, or assess the test power and significance.
- Parameters:
ax (
Axes) – Axes to draw on.**diagnostic_data – Variadic keyword arguments for the subclass implementation, taken from
RegressionTestOutcome.diagnostic_data.