pytyche.metrics

v2 metric dispatch registry.

Maps metric_id to model structure and extraction config. Single source of truth for metric → model routing in the v2 pipeline. No v1 dependency.

Functions

get_metric_config(metric)

Look up metric config by canonical metric name.

Classes

MetricConfig(metric_id, metric_family, ...)

Maps a metric to its model, posterior extraction, and lift semantics.

class pytyche.metrics.MetricConfig(metric_id, metric_family, model_id, posterior_prefix, lift_unit, component_prefixes)[source]

Bases: object

Maps a metric to its model, posterior extraction, and lift semantics.

metric_id

Canonical metric name (e.g. "conversion_rate").

metric_family

Abstract metric family from the contract enum.

model_id

Which PyMC model to fit.

posterior_prefix

Variable name prefix in the posterior (e.g. "p" for p_arm0).

lift_unit

Unit for lift samples ("pct" for relative, "dollar" for absolute).

component_prefixes

Prefixes of decomposition effect deterministics in the posterior (e.g. ("frequency", "severity") maps to frequency_effect_arm1_vs_arm0). Empty tuple for metrics without decomposition.

Parameters:
  • metric_id (str)

  • metric_family (MetricFamily)

  • model_id (Literal['binary', 'hurdle_lognormal'])

  • posterior_prefix (str)

  • lift_unit (str)

  • component_prefixes (tuple[str, ...])

pytyche.metrics.get_metric_config(metric)[source]

Look up metric config by canonical metric name.

Raises:

ValueError – If metric is not in the registry.

Parameters:

metric (str)

Return type:

MetricConfig