#[non_exhaustive]pub struct ExperimentConfig {
pub id: String,
pub primary: MetricSpec,
pub guardrails: Vec<GuardrailSpec>,
pub budget: ErrorBudget,
pub method: AnalysisMethod,
pub planned_units_per_arm: u64,
pub min_units_per_arm: u64,
pub max_units_per_arm: Option<u64>,
}Expand description
The configuration of one experiment: a control, one variant, a primary metric, guardrails, the error budget and the analysis method (spec 3.5 §7.12).
§Example
use adk_eval::experiments::{
ExperimentConfig, GuardrailSpec, MetricDirection, MetricSpec, Tolerance,
};
let config = ExperimentConfig::new(
"headline",
MetricSpec::proportion("signups", MetricDirection::HigherIsBetter),
)
.with_guardrail(GuardrailSpec::new(
MetricSpec::proportion("unsubscribes", MetricDirection::LowerIsBetter),
Tolerance::Relative(0.1),
))
.with_planned_units_per_arm(20_000);
assert!(config.validate().is_ok());Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: StringThe experiment’s id.
primary: MetricSpecThe metric the experiment tries to improve.
guardrails: Vec<GuardrailSpec>The metrics the variant must not make worse (A-I15).
budget: ErrorBudgetThe fixed type I error budget.
method: AnalysisMethodHow the primary metric is analysed.
planned_units_per_arm: u64The units per arm the experiment expects to reach; the sequential boundary is tightest there. It tunes power, not validity.
min_units_per_arm: u64The units each arm of a metric needs before that metric’s test may decide.
max_units_per_arm: Option<u64>When set, the experiment stops and keeps the control once both arms of the primary metric reach this many units without a decision.
Implementations§
Source§impl ExperimentConfig
impl ExperimentConfig
Sourcepub fn new(id: impl Into<String>, primary: MetricSpec) -> Self
pub fn new(id: impl Into<String>, primary: MetricSpec) -> Self
Creates a sequential experiment with no guardrails and the default budget and sizes.
Sourcepub fn with_guardrail(self, guardrail: GuardrailSpec) -> Self
pub fn with_guardrail(self, guardrail: GuardrailSpec) -> Self
Adds a guardrail.
Sourcepub fn with_budget(self, budget: ErrorBudget) -> Self
pub fn with_budget(self, budget: ErrorBudget) -> Self
Sets the error budget.
Sourcepub fn with_method(self, method: AnalysisMethod) -> Self
pub fn with_method(self, method: AnalysisMethod) -> Self
Sets the analysis method of the primary metric.
Sourcepub fn with_planned_units_per_arm(self, units: u64) -> Self
pub fn with_planned_units_per_arm(self, units: u64) -> Self
Sets the units per arm the experiment expects to reach.
Sourcepub fn with_min_units_per_arm(self, units: u64) -> Self
pub fn with_min_units_per_arm(self, units: u64) -> Self
Sets the units each arm needs before a metric’s test may decide.
Sourcepub fn with_max_units_per_arm(self, units: u64) -> Self
pub fn with_max_units_per_arm(self, units: u64) -> Self
Stops the experiment, keeping the control, once both arms reach units undecided.
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Checks the configuration.
§Errors
Returns EvalError::ConfigError naming the first invalid setting: an empty id, a
repeated metric id, an error budget outside (0, 0.5], a negative or unusable
tolerance, sizes that are zero or out of order, or Bayesian settings out of range.