pub struct ABTestEvaluator { /* private fields */ }Expand description
Evaluator that collects prediction pairs and judges the test.
Thread-safe — mutable state is wrapped in Mutex.
Implementations§
Source§impl ABTestEvaluator
impl ABTestEvaluator
Sourcepub fn new(config: ABTestConfig) -> Self
pub fn new(config: ABTestConfig) -> Self
Creates a new A/B test evaluator with the given configuration.
Sourcepub fn should_use_challenger(&self, request_id: u64) -> bool
pub fn should_use_challenger(&self, request_id: u64) -> bool
Decide whether a specific request should be routed to the challenger.
Uses a simple deterministic hash on the request_id for consistent
routing (no randomness in tight loops).
Sourcepub fn log_prediction(
&self,
actual: f64,
champion_pred: f64,
challenger_pred: f64,
)
pub fn log_prediction( &self, actual: f64, champion_pred: f64, challenger_pred: f64, )
Log a prediction pair (both champion and challenger predictions along with the actual observed value).
Sourcepub fn evaluate(&self) -> ABTestResult
pub fn evaluate(&self) -> ABTestResult
Evaluate the A/B test based on logged records.
Computes metrics over the most recent evaluation_windows records
to avoid stale early predictions diluting accuracy.
Sourcepub fn champion_metrics(&self) -> Option<VersionAccuracy>
pub fn champion_metrics(&self) -> Option<VersionAccuracy>
Champion accuracy from logged data.
Sourcepub fn challenger_metrics(&self) -> Option<VersionAccuracy>
pub fn challenger_metrics(&self) -> Option<VersionAccuracy>
Challenger accuracy from logged data.
Sourcepub fn record_count(&self) -> usize
pub fn record_count(&self) -> usize
Number of logged records.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ABTestEvaluator
impl !RefUnwindSafe for ABTestEvaluator
impl Send for ABTestEvaluator
impl Sync for ABTestEvaluator
impl Unpin for ABTestEvaluator
impl UnsafeUnpin for ABTestEvaluator
impl UnwindSafe for ABTestEvaluator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more