graphical_models.classes.dags.dag.DAG.marginal_mag
- DAG.marginal_mag(latent_nodes, relabel=None, new=True)[source]
Return the maximal ancestral graph (MAG) that results from marginalizing out
latent_nodes
.- Parameters
latent_nodes – nodes to marginalize over.
relabel – if relabel=’default’, relabel the nodes to have labels 1,2,…,(#nodes).
new – TODO - pick whether to use new or old implementation.
- Returns
AncestralGraph, the MAG resulting from marginalizing out latent_nodes.
- Return type
m
Examples
>>> from graphical_models import DAG >>> d = DAG(arcs={(1, 3), (1, 2)}) >>> mag = d.marginal_mag(latent_nodes={1}) >>> mag Directed edges: set(), Bidirected edges: {frozenset({2, 3})}, Undirected edges: set() >>> mag = d.marginal_mag(latent_nodes={1}, relabel="default") Directed edges: set(), Bidirected edges: {frozenset({0, 1})}, Undirected edges: set()