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>
impl<S: Eq + Hash + Clone> MarkovPredictor<S>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a predictor with default settings (min_observations=20, no auto-decay).
Sourcepub fn with_min_observations(n: u64) -> Self
pub fn with_min_observations(n: u64) -> Self
Create a predictor with a custom observation threshold (no auto-decay).
Sourcepub fn with_counter(
counter: TransitionCounter<S>,
min_observations: u64,
) -> Self
pub fn with_counter( counter: TransitionCounter<S>, min_observations: u64, ) -> Self
Create a predictor with a pre-loaded counter (e.g., from persistence).
Sourcepub fn enable_auto_decay(&mut self, config: DecayConfig)
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.
Sourcepub fn record_transition(&mut self, from: S, to: S)
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.
Sourcepub fn predict(&self, current_screen: &S) -> Vec<ScreenPrediction<S>>
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.
Sourcepub fn is_cold_start(&self, screen: &S) -> bool
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.
Sourcepub fn confidence(&self, screen: &S) -> f64
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.
Sourcepub fn counter(&self) -> &TransitionCounter<S>
pub fn counter(&self) -> &TransitionCounter<S>
Access the underlying transition counter.
Sourcepub fn counter_mut(&mut self) -> &mut TransitionCounter<S>
pub fn counter_mut(&mut self) -> &mut TransitionCounter<S>
Mutable access to the transition counter (for merging, decay, etc.).
Sourcepub fn min_observations(&self) -> u64
pub fn min_observations(&self) -> u64
Return the minimum observations threshold.
Trait Implementations§
Source§impl<S: Clone + Eq + Hash + Clone> Clone for MarkovPredictor<S>
impl<S: Clone + Eq + Hash + Clone> Clone for MarkovPredictor<S>
Source§fn clone(&self) -> MarkovPredictor<S>
fn clone(&self) -> MarkovPredictor<S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more