causalexplain.estimators.fci package#

Submodules#

FCI algorithm.

A graph learner which wraps the implementation of the FCI algorithm in the (c) causallearn library (py-why/causal-learn).

class FCI(name, independence_test_method='fisherz', alpha=0.05, depth=-1, max_path_length=-1, verbose=False, background_knowledge=None, show_progress=True, node_names=None, causes_only=True)[source]#

Bases: object

A graph learner which wraps the implementation of the FCI algorithm in (c) causallearn library (py-why/causal-learn).

Methods

filter_causes_only(adj_matrix)

Filter the adjacency matrix to include only causal relationships.

fit_predict(X[, X_test, ref_graph])

Fits the model to the data and returns predictions.

__init__(name, independence_test_method='fisherz', alpha=0.05, depth=-1, max_path_length=-1, verbose=False, background_knowledge=None, show_progress=True, node_names=None, causes_only=True)[source]#

Initialize the FCI algorithm creating an FCI learner.

Parameters:
  • name (str, name of the experiment)

  • independence_test_method (str, name of the function of the independence) – test method being used: [fisherz, chisq, gsq, kci] - fisherz: Fisher’s Z conditional independence test - chisq: Chi-squared conditional independence test - gsq: G-squared conditional independence test - kci: Kernel-based conditional independence test

  • alpha (float, desired significance level of independence tests) – (p_value) in (0,1)

  • depth (The depth for the fast adjacency search, or -1 if unlimited)

  • max_path_length (the maximum length of any discriminating path,) – or -1 if unlimited.

  • verbose (True is verbose output should be printed or logged)

  • background_knowledge (background knowledge)

  • causes_only (bool, if True, only causes are returned) – (default: True), by filtering the CPDAG and considering only the edges indicating a causal relationship.

fit_predict(X, X_test=None, ref_graph=None)[source]#

Fits the model to the data and returns predictions.

Parameters:
  • (pd.DataFrame) (X_test)

  • (pd.DataFrame)

  • (nx.DiGraph) (ref_graph)

  • causes_only (bool, if True, only causes are returned) – (default: True), by filtering the CPDAG and considering only the edges indicating a causal relationship.

Returns:

  • graph (a GeneralGraph object, where graph.graph[j,i]=1 and) – graph.graph[i,j]=-1 indicates i –> j , graph.graph[i,j] = graph.graph[j,i] = -1 indicates i — j, graph.graph[i,j] = graph.graph[j,i] = 1 indicates i <-> j, graph.graph[j,i]=1 and graph.graph[i,j]=2 indicates i o-> j.

  • edges (list) – Contains graph’s edges properties. If edge.properties have the Property ‘nl’, then there is no latent

    confounder. Otherwise, there are possibly latent confounders.

    If edge.properties have the Property ‘dd’, then it is definitely

    direct. Otherwise, it is possibly direct.

    If edge.properties have the Property ‘pl’, then there are

    possibly latent confounders. Otherwise, there is no latent confounder.

    If edge.properties have the Property ‘pd’, then it is possibly direct. Otherwise, it is definitely direct.

filter_causes_only(adj_matrix)[source]#

Filter the adjacency matrix to include only causal relationships.

This method processes the input adjacency matrix and creates a new matrix that only includes direct causal relationships (i.e., where i causes j).

main(dataset_name, input_path='/Users/renero/phd/data/sachs/', output_path='/Users/renero/phd/output/RC4/sachs/compared/', save=False, **kwargs)[source]#

Create a call to FCI with a sample dataset.

Module contents#