pyvale.validation.imetric module

Interface and shared types for validation metrics.

class EMetricScale(*values)[source]

Bases: Enum

Classify metric outputs by physical units or dimensionless range.

PHYSICAL = 1
DIMLESS = 2
DIMLESS_01 = 3
class EMetricCompare(*values)[source]

Bases: Enum

Identify how simulation and experimental samples are compared.

PAIRED = 1
DISTRIB = 2
CALIB = 3
class EMetricType(*values)[source]

Bases: Enum

Identify the metric algorithm used for a result field.

MAVM = 1
AVM = 2
KS = 3
CVM = 4
RMSE = 5
REL_ERR = 6
class EMetricOut(*values)[source]

Bases: Enum

Identify an individual numerical output of a metric.

D_PLUS = 1
D_MINUS = 2
DISTANCE = 3
STATISTIC = 4
ERROR = 5
class MAVMResult(d_plus, d_minus, sim_quantiles, sim_probs, exp_quantiles, exp_probs, exp_conf_lower, exp_conf_upper, alpha)[source]

Bases: object

Store Modified Area Validation Metric results for a conditional pair.

Variables:
  • d_plus (float) – Positive support-shift mismatch area in observable units.

  • d_minus (float) – Negative support-shift mismatch area magnitude in observable units.

  • sim_quantiles (ndarray) – Distinct simulation support points of shape (n_sim_support,).

  • sim_probs (ndarray) – Cumulative masses aligned with sim_quantiles, of shape (n_sim_support,).

  • exp_quantiles (ndarray) – Distinct experimental support points of shape (n_exp_support,).

  • exp_probs (ndarray) – Cumulative masses aligned with exp_quantiles, of shape (n_exp_support,).

  • exp_conf_lower (ndarray) – Experimental lower confidence quantiles of shape (n_exp_support,).

  • exp_conf_upper (ndarray) – Experimental upper confidence quantiles of shape (n_exp_support,).

  • alpha (float) – Significance level used to compute the experimental shift.

d_plus
d_minus
sim_quantiles
sim_probs
exp_quantiles
exp_probs
exp_conf_lower
exp_conf_upper
alpha
__init__(d_plus, d_minus, sim_quantiles, sim_probs, exp_quantiles, exp_probs, exp_conf_lower, exp_conf_upper, alpha)
class ScalarMetricResult(kind, value)[source]

Bases: object

Store the single value returned by a scalar metric.

Variables:
  • kind (EMetricType) – Metric identifier.

  • value (float) – Metric value in the scale declared by its strategy.

kind
value
__init__(kind, value)
class MultiMetricResult(kind, values)[source]

Bases: object

Store ordered numerical outputs returned by a multi-output metric.

Variables:
  • kind (EMetricType) – Metric identifier.

  • values (tuple[float, ]) – Numerical outputs in the order declared by get_outputs.

kind
values
__init__(kind, values)
extract_metric_outputs(result)[source]

Return numerical outputs in the metric’s declared order.

Parameters:

result (MetricResult) – Tagged scalar, multi-output, or MAVM result.

Returns:

tuple[float, ] – Numerical values in the order declared by the metric strategy.

class IValidMetric[source]

Bases: ABC

Calculate a metric from one-dimensional NumPy observations.

abstractmethod calc(sim, exp)[source]

Return a tagged metric result.

Parameters:
  • sim (ndarray) – Simulation observations of shape (n_sim_aleatory,) for one comparison.

  • exp (ndarray) – Experimental observations of shape (n_exp_aleatory,) in the same units as sim.

Returns:

MetricResult – Tagged metric result for one conditional comparison.

abstractmethod get_kind()[source]

Return the metric tag without calculating a result.

Returns:

EMetricType – Metric identifier used to key result fields.

abstractmethod get_scale()[source]

Declare the numerical scale of the metric outputs.

Returns:

EMetricScale – Physical or dimensionless scale used to interpret numerical outputs.

abstractmethod get_comparison()[source]

Declare how the metric compares sim and exp observations.

Returns:

EMetricCompare – Comparison mode declaring how observations are paired or treated as distributions.

abstractmethod get_outputs()[source]

Declare outputs in the order returned by extract_metric_outputs.

Returns:

tuple[EMetricOut, ] – Output tags in the order returned by extract_metric_outputs.