Notes on causal inference
from dowhy import CausalModel, datasets
import networkx as nx
data = datasets.linear_dataset(beta=10, num_common_causes=5, num_samples=10000)
model = CausalModel(data=data['df'], treatment=data['treatment_name'], outcome=data['outcome_name'], graph=data['gml_graph'])
g = nx.readwrite.gml.parse_gml(data['gml_graph'])
nx.draw(g, with_labels=True, node_size=1000, node_color='#ffa502')
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
~/miniconda/envs/fastpages/lib/python3.8/site-packages/networkx/utils/decorators.py in _random_state(func, *args, **kwargs)
    395         try:
--> 396             random_state_arg = args[random_state_index]
    397         except TypeError as e:

IndexError: tuple index out of range

The above exception was the direct cause of the following exception:

NetworkXError                             Traceback (most recent call last)
<ipython-input-10-0713f20f50d1> in <module>
      1 g = nx.readwrite.gml.parse_gml(data['gml_graph'])
----> 2 nx.draw(g, with_labels=True, node_size=1000, node_color='#ffa502')

~/miniconda/envs/fastpages/lib/python3.8/site-packages/networkx/drawing/nx_pylab.py in draw(G, pos, ax, **kwds)
    121         kwds["with_labels"] = "labels" in kwds
    122 
--> 123     draw_networkx(G, pos=pos, ax=ax, **kwds)
    124     ax.set_axis_off()
    125     plt.draw_if_interactive()

~/miniconda/envs/fastpages/lib/python3.8/site-packages/networkx/drawing/nx_pylab.py in draw_networkx(G, pos, arrows, with_labels, **kwds)
    331 
    332     if pos is None:
--> 333         pos = nx.drawing.spring_layout(G)  # default to spring layout
    334 
    335     draw_networkx_nodes(G, pos, **node_kwds)

~/miniconda/envs/fastpages/lib/python3.8/site-packages/decorator.py in fun(*args, **kw)
    229             if not kwsyntax:
    230                 args, kw = fix(args, kw, sig)
--> 231             return caller(func, *(extras + args), **kw)
    232     fun.__name__ = func.__name__
    233     fun.__doc__ = func.__doc__

~/miniconda/envs/fastpages/lib/python3.8/site-packages/networkx/utils/decorators.py in _random_state(func, *args, **kwargs)
    398             raise nx.NetworkXError("random_state_index must be an integer") from e
    399         except IndexError as e:
--> 400             raise nx.NetworkXError("random_state_index is incorrect") from e
    401 
    402         # Create a numpy.random.RandomState instance

NetworkXError: random_state_index is incorrect