Skip to main content

BaselineComparator

Struct BaselineComparator 

Source
pub struct BaselineComparator { /* private fields */ }
Expand description

Compares multiple models by their rolling error and tracks the current best.

Each entry is identified by a name and maintains its own RollingMae. The comparator does not store models, only error metrics, so it can be used alongside any predictor.

Implementations§

Source§

impl BaselineComparator

Source

pub fn new(names: &[&str], window_size: usize) -> Result<Self, RillError>

Create a new comparator with one entry per name and the given window size.

§Errors

Returns RillError::EmptyFeatures if names is empty, and RillError::InvalidParameter if names contains duplicates. A window_size of zero propagates RillError::InvalidWindowSize from the underlying RollingMae.

Source

pub fn record( &mut self, index: usize, truth: f64, prediction: f64, ) -> Result<(), RillError>

Record a single (truth, prediction) observation against the entry at index.

§Errors

Returns RillError::DimensionMismatch if index is out of bounds, and propagates any finiteness error from the underlying metric.

Source

pub fn update_best(&mut self) -> Option<usize>

Recompute the best entry and return the new best index if it changed.

The best entry is the one with the lowest rolling MAE among entries that have at least one observation. If all entries are empty, the best index is cleared and the last switch reason is set to SwitchReason::InsufficientData.

Returns Some(new_index) when the best entry changes, and None otherwise.

Source

pub const fn best_index(&self) -> Option<usize>

Index of the current best entry, or None if no entry has data.

Source

pub fn best_name(&self) -> Option<&str>

Name of the current best entry, or None if no entry has data.

Source

pub fn best_error(&self) -> Option<f64>

Rolling MAE of the current best entry, or None if unavailable.

Source

pub fn entry_count(&self) -> usize

Number of tracked entries.

Source

pub const fn switch_count(&self) -> u64

How many times the best entry has changed since construction or last reset.

Source

pub const fn last_switch_reason(&self) -> Option<SwitchReason>

The reason for the most recent best-entry change (or InsufficientData).

Source

pub fn entry(&self, index: usize) -> Option<&ComparatorEntry>

Borrow the entry at index, or None if out of bounds.

Source

pub fn reset(&mut self)

Reset every entry’s rolling metric and sample count, and clear all best-entry tracking state.

Trait Implementations§

Source§

impl Clone for BaselineComparator

Source§

fn clone(&self) -> BaselineComparator

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BaselineComparator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V