class dodiscover.constraint.LearnSemiMarkovianSkeleton(ci_estimator, sep_set=None, alpha=0.05, min_cond_set_size=0, max_cond_set_size=None, max_combinations=None, condsel_method=ConditioningSetSelection.NBRS, second_stage_condsel_method=ConditioningSetSelection.PDS, keep_sorted=False, max_path_length=None, n_jobs=None)[source]#

Learning a skeleton from a semi-markovian causal model.

This proceeds by learning a skeleton by testing edges with candidate separating sets from the “possibly d-separating” sets (PDS), or PDS sets that lie on a path between two nodes [1]. This algorithm requires the input of a collider-oriented PAG, which provides the necessary information to compute the PDS set for any given nodes. See Notes for more details.


The conditional independence test function.

sep_setdictionary of dictionary of list of set

Mapping node to other nodes to separating sets of variables. If None, then an empty dictionary of dictionary of list of sets will be initialized.

alphafloat, optional

The significance level for the conditional independence test, by default 0.05.


The minimum size of the conditioning set, by default 0. The number of variables used in the conditioning set.

max_cond_set_sizeint, optional

Maximum size of the conditioning set, by default None. Used to limit the computation spent on the algorithm.

max_combinationsint, optional

The maximum number of conditional independence tests to run from the set of possible conditioning sets. By default None, which means the algorithm will check all possible conditioning sets. If max_combinations=n is set, then for every conditioning set size, ‘p’, there will be at most ‘n’ CI tests run before the conditioning set size ‘p’ is incremented. For controlling the size of ‘p’, see min_cond_set_size and max_cond_set_size. This can be used in conjunction with keep_sorted parameter to only test the “strongest” dependences.


The method to use for determining conditioning sets when testing conditional independence of the first stage. See LearnSkeleton for details.

second_stage_condsel_methodConditioningSetSelection | None

The method to use for determining conditioning sets when testing conditional independence of the first stage. Must be one of (‘pds’, ‘pds_path’). See Notes for more details. If None, then no second stage skeleton discovery phase will be run.


Whether or not to keep the considered conditioning set variables in sorted dependency order. If True (default) will sort the existing dependencies of each variable by its dependencies from strongest to weakest (i.e. largest CI test statistic value to lowest). This can be used in conjunction with max_combinations parameter to only test the “strongest” dependences.

max_path_lengthint, optional

The maximum length of any discriminating path, or None if unlimited.


To learn the skeleton of a Semi-Markovian causal model, one approach is to consider the possibly d-separating (PDS) set, which is a superset of the d-separating sets in the true causal model. Knowing the PDS set requires knowledge of the skeleton and orientation of certain edges. Therefore, we first learn an initial skeleton by checking conditional independences with respect to node neighbors. From this, one can orient certain colliders. The resulting PAG can now be used to enumerate the PDS sets for each node, which are now conditioning candidates to check for conditional independence.

For visual examples, see Figures 16, 17 and 18 in [1]. Also, see the RFCI paper for other examples [2].

Different methods for learning the skeleton:

There are different ways to learn the skeleton that are valid under various assumptions. The value of condsel_method completely defines how one selects the conditioning set.

  • ‘pds’: This conditions on the PDS set of ‘x_var’. Note, this definition does not rely on ‘y_var’. See [1].

  • ‘pds_path’: This is ‘pds’, but restricts to variables with a possibly directed path from ‘x_var’ to ‘y_var’. This is a variant from the RFCI paper [2].



The discovered graph from data. Stored using an undirected graph. The graph contains edge attributes for the smallest value of the test statistic encountered (key name ‘test_stat’), the largest pvalue seen in testing ‘x’ || ‘y’ given some conditioning set (key name ‘pvalue’).

sep_set_dictionary of dictionary of list of set

Mapping node to other nodes to separating sets of variables.


The result context. Encodes causal assumptions.


The inferred minimum conditioning set size.


The inferred maximum conditioning set size.


The inferred maximum number of combinations of ‘Z’ to test per \(X \perp Y | Z\).


The number of iterations the skeleton has been learned.


Th inferred maximum path length any single discriminating path is allowed to take.

n_jobsint, optional

Number of CPUs to use, by default None.


evaluate_edge(data, conditional_test_func, X, Y)

Test any specific edge for X || Y | Z.



Callable[[Column, Column, Set[Column]], Tuple[float, float]]

evaluate_edge(data, conditional_test_func, X, Y, Z=None)#

Test any specific edge for X || Y | Z.


The dataset


A column in data.


A column in data.

Zset, optional

A list of columns in data, by default None.


Test statistic.


The pvalue.