Graph Examples
Examples from CausalFusion.
- backdoor = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
Treatment: X Outcome: Y Adjusted: N/A
- frontdoor = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
Treatment: X Outcome: Y Adjusted: N/A
- frontdoor_backdoor = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
Treatment: X Outcome: Y Adjusted: N/A
- instrumental_variable = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
Treatment: X Outcome: Y
- napkin = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
Treatment: X Outcome: Y
- generate_napkin_data(num_samples: int, treatments: dict[Variable, float] | None = None, *, seed: int | None = None) DataFrame[source]
Generate testing data for the napkin graph.
- Parameters:
num_samples – The number of samples to generate. Try 1000.
treatments – An optional dictionary of the values to fix each variable to. The keys in this dictionary must correspond to variables in the napkin graph as defined in
y0.examples.napkin(i.e., withy0.dsl.Z1,y0.dsl.Z2,y0.dsl.X, andy0.dsl.Y).seed – An optional random seed for reproducibility purposes
- Returns:
A pandas Dataframe with columns corresponding to the four variable names in the Napkin graph (i.e.,
Z1,Z2,X, andY)
Generate _observational_ data with the following:
>>> from y0.examples.napkin_example >>> napkin_example.generate_data(1000)
Generate interventional data on \(X=1\) with the following:
>>> from y0.dsl import X >>> napkin_example.generate_data(1000, treatments={X: 1})
Multiple treatments can be specified:
>>> from y0.dsl import X, Z1 >>> napkin_example.generate_data(1000, treatments={X: 1, Z1: 0})
- m_graph = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
Treatment: X Outcome: Y Reference:
- identifiability_1 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
Treatment: X Outcome: Y
- identifiability_2 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
Treatment: X Outcome: Y
- identifiability_3 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
The Identifiability 3 example Treatment: X Outcome: Y Reference: J. Pearl. 2009. “Causality: Models, Reasoning and Inference. 2nd ed.” Cambridge University Press, p. 92.
- identifiability_4 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
The Identifiability 4 example Treatment: X Outcome: Y Reference: J. Pearl. 2009. “Causality: Models, Reasoning and Inference. 2nd ed.” Cambridge University Press, p. 92.
- identifiability_5 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
The Identifiability 5 example Treatment: X1, X2 Outcome: Y Reference: J. Pearl. 2009. “Causality: Models, Reasoning and Inference. 2nd ed.” Cambridge University Press, p. 119.
- identifiability_6 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
The Identifiability 6 example Treatment: X1, X2 Outcome: Y Reference: J. Pearl. 2009. “Causality: Models, Reasoning and Inference. 2nd ed.” Cambridge University Press, p. 125.
- identifiability_7 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
The Identifiability 7 example Treatment: X Outcome: Y Reference: J. Tian. 2002. “Studies in Causal Reasoning and Learning.” p. 90.
- verma_1 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
The Verma 1 example Treatment: V3 Outcome: V4 Reference: T. Verma and J. Pearl. 1990. “Equivalence and Synthesis of Causal Models.” In P. Bonissone et al., eds., Proceedings of the 6th Conference on Uncertainty in Artificial Intelligence. Cambridge, MA: AUAI Press, p. 257.
- verma_2 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
The Verma 2 example Treatment: V1 Outcome: V5 Reference: J. Tian. 2002. “Studies in Causal Reasoning and Learning.” p. 70.
- verma_3 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
The Verma 3 example Treatment: V1 Outcome: V5 Reference: J. Tian. 2002. “Studies in Causal Reasoning and Learning.” p. 59.
- verma_4 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
The Verma 4 example Treatment: V1 Outcome: V5 Reference: E. Bareinboim modification of Verma 2.
- verma_5 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
The Verma 5 example Treatment: V1 Outcome: V5 Reference: E. Bareinboim modification of Verma 2.
- z_identifiability_1 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
The z-Identifiability 1 example Treatment: X Outcome: Y Z*: Z Reference: E. Bareinboim and J. Pearl. 2012. “Causal Inference by Surrogate Experiments: z-Identifiability.” In Nando de Freitas and K. Murphy., eds., Proceedings of the 28th Conference on Uncertainty in Artificial Intelligence. Corvallis, OR: AUAI Press, p. 114.
- z_identifiability_2 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
The z-Identifiability 2 example Treatment: X Outcome: Y Z*: Z Reference: E. Bareinboim and J. Pearl. 2012. “Causal Inference by Surrogate Experiments: z-Identifiability.” In Nando de Freitas and K. Murphy., eds., Proceedings of the 28th Conference on Uncertainty in Artificial Intelligence. Corvallis, OR: AUAI Press, p. 114.
- z_identifiability_3 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
The z-Identifiability 3 example Treatment: X Outcome: Y Z*: Z Reference: E. Bareinboim and J. Pearl. 2012. “Causal Inference by Surrogate Experiments: z-Identifiability.” In Nando de Freitas and K. Murphy., eds., Proceedings of the 28th Conference on Uncertainty in Artificial Intelligence. Corvallis, OR: AUAI Press, p. 114.
- identifiability_linear_1 = NxMixedGraph(directed=<networkx.classes.digraph.DiGraph object>, undirected=<networkx.classes.graph.Graph object>)
The Identifiability (Linear) 1 example Treatment: X Outcome: Y Reference: J. Pearl. 2009. “Causality: Models, Reasoning and Inference. 2nd ed.” Cambridge University Press, p. 153.