pub struct MarkovModel { /* private fields */ }
Expand description
Variable-order Markov model for sequence analysis
Implementations§
Source§impl MarkovModel
impl MarkovModel
Sourcepub fn new(max_order: usize) -> AnomalyGridResult<Self>
pub fn new(max_order: usize) -> AnomalyGridResult<Self>
Create a new Markov model with specified maximum order
Sourcepub fn with_config(config: AnomalyGridConfig) -> AnomalyGridResult<Self>
pub fn with_config(config: AnomalyGridConfig) -> AnomalyGridResult<Self>
Create a new Markov model with custom configuration
Sourcepub fn train(&mut self, sequence: &[String]) -> AnomalyGridResult<()>
pub fn train(&mut self, sequence: &[String]) -> AnomalyGridResult<()>
Sourcepub fn calculate_likelihood(&self, sequence: &[String]) -> f64
pub fn calculate_likelihood(&self, sequence: &[String]) -> f64
Calculate the likelihood of a sequence under the model
Sourcepub fn get_best_context_probability(
&self,
context: &[String],
next_state: &str,
) -> f64
pub fn get_best_context_probability( &self, context: &[String], next_state: &str, ) -> f64
Get the best context probability using adaptive hierarchical context selection
Sourcepub fn config(&self) -> &AnomalyGridConfig
pub fn config(&self) -> &AnomalyGridConfig
Get the configuration
Sourcepub fn state_mapping(&self) -> &HashMap<String, usize>
pub fn state_mapping(&self) -> &HashMap<String, usize>
Get the state mapping
Sourcepub fn context_tree(&self) -> &ContextTree
pub fn context_tree(&self) -> &ContextTree
Get the context tree
Sourcepub fn context_tree_mut(&mut self) -> &mut ContextTree
pub fn context_tree_mut(&mut self) -> &mut ContextTree
Get mutable access to the context tree (for optimizations)
Sourcepub fn get_marginal_probability(&self, state: &str) -> f64
pub fn get_marginal_probability(&self, state: &str) -> f64
Get marginal probability of a state from the training data
Sourcepub fn get_background_probability(&self, state: &str) -> f64
pub fn get_background_probability(&self, state: &str) -> f64
Get background probability for unseen transitions (public for adaptive scoring)
Trait Implementations§
Source§impl Clone for MarkovModel
impl Clone for MarkovModel
Source§fn clone(&self) -> MarkovModel
fn clone(&self) -> MarkovModel
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for MarkovModel
impl RefUnwindSafe for MarkovModel
impl Send for MarkovModel
impl Sync for MarkovModel
impl Unpin for MarkovModel
impl UnwindSafe for MarkovModel
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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