Skip to main content

MarkovPredictor

Struct MarkovPredictor 

Source
pub struct MarkovPredictor<S: Eq + Hash + Clone> { /* private fields */ }
Expand description

Markov-chain predictor wrapping a TransitionCounter.

Provides prediction queries with confidence-aware blending between observed transition probabilities and a uniform fallback.

Implementations§

Source§

impl<S: Eq + Hash + Clone> MarkovPredictor<S>

Source

pub fn new() -> Self

Create a predictor with default settings (min_observations=20, no auto-decay).

Source

pub fn with_min_observations(n: u64) -> Self

Create a predictor with a custom observation threshold (no auto-decay).

Source

pub fn with_counter( counter: TransitionCounter<S>, min_observations: u64, ) -> Self

Create a predictor with a pre-loaded counter (e.g., from persistence).

Source

pub fn enable_auto_decay(&mut self, config: DecayConfig)

Enable automatic temporal decay on record_transition() calls.

Every config.interval record calls, all counts are multiplied by config.factor, causing old transition data to fade over time.

Source

pub fn record_transition(&mut self, from: S, to: S)

Record a screen transition.

If auto-decay is enabled, this may trigger a decay cycle after every interval calls.

Source

pub fn predict(&self, current_screen: &S) -> Vec<ScreenPrediction<S>>

Predict likely next screens from current_screen.

Returns predictions sorted by effective probability (descending). Each prediction blends observed and uniform probabilities based on confidence.

Source

pub fn is_cold_start(&self, screen: &S) -> bool

Check whether predictions from screen have insufficient data.

Returns true if fewer than min_observations transitions have been recorded from this screen.

Source

pub fn confidence(&self, screen: &S) -> f64

Confidence level for predictions from screen (0.0..1.0).

Grows linearly from 0 to 1 as observations approach min_observations.

Source

pub fn counter(&self) -> &TransitionCounter<S>

Access the underlying transition counter.

Source

pub fn counter_mut(&mut self) -> &mut TransitionCounter<S>

Mutable access to the transition counter (for merging, decay, etc.).

Source

pub fn min_observations(&self) -> u64

Return the minimum observations threshold.

Trait Implementations§

Source§

impl<S: Clone + Eq + Hash + Clone> Clone for MarkovPredictor<S>

Source§

fn clone(&self) -> MarkovPredictor<S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<S: Debug + Eq + Hash + Clone> Debug for MarkovPredictor<S>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<S: Eq + Hash + Clone> Default for MarkovPredictor<S>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S> Freeze for MarkovPredictor<S>

§

impl<S> RefUnwindSafe for MarkovPredictor<S>
where S: RefUnwindSafe,

§

impl<S> Send for MarkovPredictor<S>
where S: Send,

§

impl<S> Sync for MarkovPredictor<S>
where S: Sync,

§

impl<S> Unpin for MarkovPredictor<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for MarkovPredictor<S>

§

impl<S> UnwindSafe for MarkovPredictor<S>
where S: UnwindSafe,

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<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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more