Hypothesis
hypothesis
Hypothesis specification layer binding metrics to targeted statistical directions.
This module provides the HypothesisSpec container, which formalizes the core scientific or
business claim under test, linking it directly to an evaluation metric and establishing the
mathematical directionality (one-sided vs. two-sided) of the downstream inference testing.
| CLASS | DESCRIPTION |
|---|---|
HypothesisSpec |
Specifies the hypothesis under test and binds it to a primary metric. |
HypothesisSpec
HypothesisSpec(
primary_metric: BaseMetric,
direction: Literal[
"two-sided", "greater", "less"
] = "two-sided",
description: str = "",
)
Specifies the hypothesis under test and binds it to a primary metric.
This class serves as the formal pre-registered scientific statement of the experiment's goal, preventing retrospective hypothesis adjustments after seeing results (HARKing). It defines the directional expectation of the treatment effect.
Mathematical Specifications
Let \(\theta_C\) and \(\theta_T\) represent the true population parameter (e.g., mean, rate, or ratio)
of the control and treatment groups, respectively, for the bound primary_metric.
"two-sided"(Default): Tests for any difference between arms, representing the standard industrial default. $$ H_0: \theta_T = \theta_C \quad \text{vs.} \quad H_1: \theta_T \neq \theta_C $$"greater"(One-sided upper-tailed): Tests whether treatment is strictly better than control. $$ H_0: \theta_T \le \theta_C \quad \text{vs.} \quad H_1: \theta_T > \theta_C $$"less"(One-sided lower-tailed): Tests whether treatment is strictly worse than control (typically used for testing negative side effects or latency increases). $$ H_0: \theta_T \ge \theta_C \quad \text{vs.} \quad H_1: \theta_T < \theta_C $$
Attributes: primary_metric (BaseMetric): The registered metric used as the primary outcome variable for evaluating this hypothesis. direction (Literal["two-sided", "greater", "less"]): The directional mathematical sign of the statistical test. Defaults to "two-sided". description (str): Text describing the business or scientific hypothesis in natural language.
Examples:
Example
>>> from xpyrment.metrics.taxonomy import ProportionMetric
>>> from xpyrment.plan.hypothesis import HypothesisSpec
>>> conv_metric = ProportionMetric("Conversion Rate", value_col="converted")
>>> spec = HypothesisSpec(
... primary_metric=conv_metric,
... direction="greater",
... description="Redesigned checkout button increases conversion rates."
... )
>>> spec.direction
'greater'
| PARAMETER | DESCRIPTION |
|---|---|
primary_metric
|
The evaluation metric being tested.
TYPE:
|
direction
|
The statistical test directionality.
Options are
TYPE:
|
description
|
A descriptive summary of the business hypothesis. Defaults to "".
TYPE:
|