causal_networkx.discovery.FCI#

class causal_networkx.discovery.FCI(ci_estimator, alpha=0.05, init_graph=None, fixed_edges=None, min_cond_set_size=None, max_cond_set_size=None, max_iter=1000, max_combinations=None, apply_orientations=True, selection_bias=False, max_path_length=None, augmented=False, **ci_estimator_kwargs)[source]#

Methods

fit(X)

Fit constraint-based discovery algorithm on dataset 'X'.

learn_skeleton(X[, graph, sep_set, fixed_edges])

Learn skeleton from data.

test_edge(data, X, Y[, Z])

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

convert_skeleton_graph

orient_edges

fit(X)#

Fit constraint-based discovery algorithm on dataset ‘X’.

Parameters:

X : Union[pd.DataFrame, Dict[Set, pd.DataFrame]]

Either a pandas dataframe constituting the endogenous (observed) variables as columns and samples as rows, or a dictionary of different sampled distributions with keys as the distribution names and values as the dataset as a pandas dataframe.

Raises:

RuntimeError

If ‘X’ is a dictionary, then all datasets should have the same set of column names (nodes).

Notes

Control over the constraints imposed by the algorithm can be passed into the class constructor.

Return type:

None

learn_skeleton(X, graph=None, sep_set=None, fixed_edges=None)[source]#

Learn skeleton from data.

Parameters:

X : pd.DataFrame

Dataset.

graph : nx.Graph

The undirected graph containing initialized skeleton of the causal relationships.

sep_set : set

The separating set.

fixed_edges : set, optional

The set of fixed edges. By default, is the empty set.

Returns:

pag : PAG

The skeleton graph.

sep_set : Dict[str, Dict[str, Set]]

The separating set.

:rtype:py:data:Tuple[Graph, Dict[str, Dict[str, Set[Any]]], Dict[Any, Dict[Any, float]], Dict[Any, Dict[Any, float]]]
test_edge(data, X, Y, Z=None)#

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

Parameters:

data : pd.DataFrame

The dataset

X : column

A column in data.

Y : column

A column in data.

Z : list, optional

A list of columns in data, by default None.

Returns:

test_stat : float

Test statistic.

pvalue : float

The pvalue.

Examples using causal_networkx.discovery.FCI#