pub struct CausalDiscovery {
pub n_vars: usize,
pub skeleton: Vec<Vec<bool>>,
pub directed: Vec<Vec<bool>>,
pub sep_sets: HashMap<(usize, usize), Vec<usize>>,
pub alpha: f64,
}Expand description
Causal discovery via the PC algorithm.
The PC algorithm learns the structure of a DAG from conditional independence tests on observational data. It produces a Completed Partially Directed Acyclic Graph (CPDAG) representing the Markov equivalence class.
Fields§
§n_vars: usizeNumber of variables.
skeleton: Vec<Vec<bool>>Adjacency matrix of the skeleton (undirected).
directed: Vec<Vec<bool>>Directed adjacency: directed[i][j] = true means i → j is oriented.
sep_sets: HashMap<(usize, usize), Vec<usize>>Separation sets: sep_sets[(i,j)] = the conditioning set that d-separates i and j.
alpha: f64Significance threshold for independence tests.
Implementations§
Source§impl CausalDiscovery
impl CausalDiscovery
Sourcepub fn new(n_vars: usize, alpha: f64) -> Self
pub fn new(n_vars: usize, alpha: f64) -> Self
Create a new PC algorithm runner.
§Arguments
n_vars— number of observed variablesalpha— significance level for conditional independence tests
Sourcepub fn learn_skeleton(&mut self, data: &[Vec<f64>])
pub fn learn_skeleton(&mut self, data: &[Vec<f64>])
Learn the skeleton from a data matrix using partial correlation tests.
§Arguments
data— data matrix, shape[n_obs][n_vars]
Sourcepub fn orient_v_structures(&mut self)
pub fn orient_v_structures(&mut self)
Orient v-structures (colliders) in the skeleton.
For each unshielded triple i — k — j (i and j not adjacent), if k is not in sep(i,j), orient i→k←j.
Sourcepub fn apply_meek_rules(&mut self)
pub fn apply_meek_rules(&mut self)
Apply Meek’s orientation rules to complete the CPDAG.
Rules R1–R3 propagate orientations to avoid new v-structures and cycles.
Trait Implementations§
Source§impl Clone for CausalDiscovery
impl Clone for CausalDiscovery
Source§fn clone(&self) -> CausalDiscovery
fn clone(&self) -> CausalDiscovery
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CausalDiscovery
impl RefUnwindSafe for CausalDiscovery
impl Send for CausalDiscovery
impl Sync for CausalDiscovery
impl Unpin for CausalDiscovery
impl UnsafeUnpin for CausalDiscovery
impl UnwindSafe for CausalDiscovery
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.