1.4.1. dodiscover.constraint.PsiFCI#
- class dodiscover.constraint.PsiFCI(ci_estimator, cd_estimator, alpha=0.05, min_cond_set_size=None, max_cond_set_size=None, max_combinations=None, condsel_method=ConditioningSetSelection.NBRS, apply_orientations=True, keep_sorted=False, max_iter=1000, max_path_length=None, pds_condsel_method=ConditioningSetSelection.PDS, known_intervention_targets=False, n_jobs=None)[source]#
Interventional (Psi) FCI algorithm.
The I-FCI (or Psi-FCI) algorithm is an algorithm that accepts multiple sets of data that may pertain to observational and/or multiple interventional datasets under a known (I-FCI), or unknown (Psi-FCI) intervention target setting. Our API consolidates them here under one class, but you can control the setting using our hyperparameter. See [1] for more information on I-FCI and [2] for more information on Psi-FCI.
The Psi-FCI algorithm is complete for the Psi-PAG equivalence class. However, the I-FCI has not been shown to be complete for the I-PAG equivalence class. Note that the I-FCI algorithm may change without notice.
- Parameters:
- ci_estimator
BaseConditionalIndependenceTest
The conditional independence test function. The arguments of the estimator should be data, node, node to compare, conditioning set of nodes, and any additional keyword arguments.
- cd_estimator
BaseConditionalDiscrepancyTest
The conditional discrepancy test function.
- alpha
float
, optional The significance level for the conditional independence test, by default 0.05.
- min_cond_set_size
int
, optional Minimum size of the conditioning set, by default None, which will be set to ‘0’. Used to constrain the computation spent on the algorithm.
- max_cond_set_size
int
, optional Maximum size of the conditioning set, by default None. Used to limit the computation spent on the algorithm.
- max_combinations
int
, 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’, seemin_cond_set_size
andmax_cond_set_size
. This can be used in conjunction withkeep_sorted
parameter to only test the “strongest” dependences.- condsel_method
ConditioningSetSelection
The method to use for selecting the conditioning sets. Must be one of (‘neighbors’, ‘complete’, ‘neighbors_path’). See Notes for more details.
- apply_orientationsbool
Whether or not to apply orientation rules given the learned skeleton graph and separating set per pair of variables. If
True
(default), will apply Zhang’s orientation rules R0-10, orienting colliders and certain arrowheads and tails [3].- keep_sortedbool
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). The conditioning set is chosen lexographically based on the sorted test statistic values of ‘ith Pa(X) -> X’, for each possible parent node of ‘X’. This can be used in conjunction with
max_combinations
parameter to only test the “strongest” dependences.- max_iter
int
The maximum number of iterations through the graph to apply orientation rules.
- max_path_length
int
, optional The maximum length of any discriminating path, or None if unlimited.
- pds_condsel_method
ConditioningSetSelection
The method to use for selecting the conditioning sets using PDS. Must be one of (‘pds’, ‘pds_path’). See Notes for more details.
- known_intervention_targetsbool, optional
If
True
, then will run the I-FCI algorithm. IfFalse
, will run the Psi-FCI algorithm. By default False.- n_jobs
int
, optional The number of parallel jobs to run. If -1, then the number of jobs is set to the number of cores. If 1 is given, no parallel computing code is used at all, By default None, which means 1.
- ci_estimator
Notes
Selection bias is unsupported because it is still an active research area.
Methods
evaluate_edge
(data, X, Y[, Z])Test any specific edge for X || Y | Z.
learn_graph
(data, context)Learn the relevant causal graph equivalence class.
learn_skeleton
(data, context[, sep_set])Learns the skeleton of a causal DAG using pairwise (conditional) independence testing.
orient_edges
(graph)Apply orientations to edges using logical rules.
orient_unshielded_triples
(graph, sep_set)Orient colliders given a graph and separation set.
convert_skeleton_graph
- evaluate_edge(data, X, Y, Z=None)#
Test any specific edge for X || Y | Z.
- learn_graph(data, context)[source]#
Learn the relevant causal graph equivalence class.
From the pairs of datasets, we take all combinations and construct F-nodes corresponding to those.
- Parameters:
- data
List
[pd.DataFrame
] The list of different datasets assigned to different environments. We assume the first dataset is always observational.
- context
Context
The context with interventional assumptions.
- data
- Returns:
- selfPsiFCI
The fitted learner.
- learn_skeleton(data, context, sep_set=None)[source]#
Learns the skeleton of a causal DAG using pairwise (conditional) independence testing.
Encodes the skeleton via an undirected graph,
networkx.Graph
.- Parameters:
- Returns:
Notes
Learning the skeleton of a causal DAG uses (conditional) independence testing to determine which variables are (in)dependent. This specific algorithm compares exhaustively pairs of adjacent variables.
- orient_edges(graph)#
Apply orientations to edges using logical rules.
- Parameters:
- graph
EquivalenceClass
Causal graph.
- graph
- Raises:
NotImplementedError
All constraint-based discovery algorithms must implement this.
- orient_unshielded_triples(graph, sep_set)#
Orient colliders given a graph and separation set.
- Parameters:
- graph
EquivalenceClass
The partial ancestral graph (PAG).
- sep_set
SeparatingSet
The separating set between any two nodes.
- graph