Misc module

causalai.misc.misc

Contains code for graph plotting and computing precision/recall for comparing correctness of estimated causal graph with a given ground truth graph.

causalai.misc.misc.get_precision_recall(G, G_gt)

Computes the average precision, recall and F1 score of the estimated causal graph given the ground truth causal graph across variables. Supports both time series and tabular data causal graphs.

Parameters:
  • G (dict) -- estimated causal graph

  • G_gt (dict) -- ground truth causal graph

causalai.misc.misc.get_precision_recall_skeleton(G, G_gt)

Computes the average precision, recall and F1 score of the estimated undirected causal graph given the ground truth directed causal graph across variables. Supports tabular data causal graphs only.

Parameters:
  • G (dict) -- estimated causal graph

  • G_gt (dict) -- ground truth causal graph

causalai.misc.misc.make_symmetric(graph)
causalai.misc.misc.plot_graph(graph, filename='', node_size=1000)

Examples:

Tabular graph:

g = {'A': ['B', 'C'],

'B': ['C', 'D'], 'C': []}

plot_graph(g)

Time series graph:

g = {'A': [('B',-1), ('C', -5)],

'B': [('C', -1), ('D',-3)]}

plot_graph(g)