pub struct BayesianNode {
pub node_type: NodeType,
pub states: Vec<String>,
pub prior: Vec<f64>,
pub parents: Vec<String>,
pub cpt: HashMap<String, Vec<f64>>,
pub mean: f64,
pub std: f64,
}Expand description
A node in the Bayesian network
Fields§
§node_type: NodeTypeNode type
states: Vec<String>Possible states (for discrete nodes)
prior: Vec<f64>Prior probabilities (for root nodes)
parents: Vec<String>Parent node names
cpt: HashMap<String, Vec<f64>>Conditional probability table (CPT) Keys are parent state combinations, values are probabilities for this node’s states
mean: f64For continuous nodes: mean
std: f64For continuous nodes: standard deviation
Implementations§
Source§impl BayesianNode
impl BayesianNode
Sourcepub fn continuous(mean: f64, std: f64) -> Self
pub fn continuous(mean: f64, std: f64) -> Self
Create a new continuous node
Sourcepub fn with_prior(self, prior: Vec<f64>) -> Self
pub fn with_prior(self, prior: Vec<f64>) -> Self
Set prior probabilities (for root nodes)
Sourcepub fn with_parents(self, parents: Vec<&str>) -> Self
pub fn with_parents(self, parents: Vec<&str>) -> Self
Set parent nodes
Sourcepub fn with_cpt_entry(self, parent_state: &str, probs: Vec<f64>) -> Self
pub fn with_cpt_entry(self, parent_state: &str, probs: Vec<f64>) -> Self
Add CPT entry
Trait Implementations§
Source§impl Clone for BayesianNode
impl Clone for BayesianNode
Source§fn clone(&self) -> BayesianNode
fn clone(&self) -> BayesianNode
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 moreSource§impl Debug for BayesianNode
impl Debug for BayesianNode
Source§impl<'de> Deserialize<'de> for BayesianNode
impl<'de> Deserialize<'de> for BayesianNode
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for BayesianNode
impl RefUnwindSafe for BayesianNode
impl Send for BayesianNode
impl Sync for BayesianNode
impl Unpin for BayesianNode
impl UnsafeUnpin for BayesianNode
impl UnwindSafe for BayesianNode
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