FenTechSolutions / CausalDiscoveryToolbox

Package for causal inference in graphs and in the pairwise settings. Tools for graph structure recovery and dependencies are included.
https://fentechsolutions.github.io/CausalDiscoveryToolbox/html/index.html
MIT License
1.12k stars 197 forks source link

How to generate single-direction graph with SAM? #116

Open Gaohan123 opened 2 years ago

Gaohan123 commented 2 years ago

Hi~Thanks for your kind sharing. I run SAM algorithm with my own dataset. First I use the API to generate a graph: skeleton = sam.create_graph_from_data(data) Then I use another API to remove indirect edges: new_skeleton = cdt.utils.graph.remove_indirect_links(skeleton, alg='aracne') Later I do causal discovery with the API: output = sam.predict(data, new_skeleton)

However, I find that every edge of the graph is still bidirectional. Is there a way to generate single-direction graph? After all, causal relationship must have certain direction. Thank you!

diviyank commented 2 years ago

Hello, There is no need for the input of SAM to be preprocessed with a algorithm such as ARACNE. The best is to give the full data to the model.

One execution of SAM provides a binary adjacency matrix representing the predicted causal graph. We noticed however that running SAM multiple times and averaging the results does provide better performance.

The output of the function is thus a matrix with confidence scores on each edge. From there on; it's up to the user to threshold between 0 and 1 according to the desired precision-recall. We noticed that one of the best values to threshold on is .7, as the resulting edges are a DAG and provides good performance.

Best regards, Diviyan