Maximally oriented PDAG (MPDAG)
- class pyagrum.MPDAG(*args)
MPDAG represents a maximally oriented PDAG: a CPDAG refined by background knowledge.
A PDAG represents the DAGs with its skeleton, its v-structures and containing its arcs (its consistent extensions). Its maximal orientation (MPDAG) orients every edge that has the same orientation in all these DAGs: it is the closure of the PDAG under the Meek rules (Meek 1995). A CPDAG with some imposed arcs gives an MPDAG (Perković, Kalisch and Maathuis 2017). An MPDAG is not always a chain graph.
An MPDAG cannot be modified: it is built by
MPDAG.meekClosure(),MPDAG.fromCPDAG()or checked byMPDAG.fromPDAG(). The represented DAGs are Markov equivalent:dSeparation()is the d-separation of any of them.
Example
import pyagrum as gum
cpdag = gum.CPDAG.fromDAG(gum.fastDAG("A->B->C"))
sorted(cpdag.edges())
# [(0, 1), (1, 2)]
mpdag = gum.MPDAG.fromCPDAG(cpdag, [(0, 1)]) # A->B imposed, then B->C by the Meek rules
sorted(mpdag.arcs()), sorted(mpdag.edges())
# ([(0, 1), (1, 2)], [])
Scientific notes
An MPDAG (maximally oriented PDAG) is a PDAG closed under the four Meek rules (stated in pyagrum.MeekRules). An
extendable PDAG \(G\) represents the set \([G]\) of its consistent extensions (see pyagrum.PDAG); its closure
under the rules orients exactly the edges that have the same orientation in all the DAGs of \([G]\)
[1] (Theorem 4). The typical MPDAG is a CPDAG (pyagrum.CPDAG) refined by arcs imposed by
background knowledge [2]: fromCPDAG imposes the arcs, raises an error if no DAG of
the class contains them all (a directed cycle, for instance), and closes the result under the rules.
An MPDAG is not always a chain graph: imposing \(a \to b\) in the undirected triangle \(a - b - c - a\) orients
nothing else, which leaves the partially directed cycle \(a \to b - c - a\). meekClosure computes the closure
of an extendable PDAG with Algorithm 2 of [3]: from a consistent extension \(D\), it
starts from the CPDAG of \(D\), gives its undirected edges the orientation of the PDAG, then visits the nodes once
in a topological order of \(D\), orienting the edges into the current node by R1, R4, then R2 (R3 never applies
there). fromPDAG accepts a PDAG iff it is extendable and closed under the rules; an MPDAG is immutable.
The DAGs of \([G]\) are Markov equivalent (same skeleton and v-structures [4]): cpdag
returns the CPDAG of their class, and dSeparation is the d-separation of any of them, computed on a consistent
extension kept from the construction.
Methods
adjacency matrix from a graph/graphical models |
|
The connected components of the graph (of its skeleton). |
|
number of connected components |
|
connected components as a dict of sets |
|
Check if the sets of nodes X and Y are d-separated (by the set of nodes Z if given) in every DAG represented by the MPDAG. |
|
The MPDAG of a CPDAG with some arcs imposed by background knowledge. |
|
Checked conversion of a PDAG into an MPDAG: the PDAG must be extendable and closed under the Meek rules. |
|
Return the id of the node with the given name, or None if no such name exists. |
|
The ids of nodes given by their names, in a container of the same type. |
|
The maximal orientation of an extendable PDAG (its closure under the Meek rules). |
|
Return the name of a node, or its id as a string if no name was set. |
|
The names of nodes given by their ids, in a container of the same type. |
|
Save the graph as a .jgum (text) or .bgum (binary) file (its class, its nodes with their names, its arcs, edges and marks). |
|
Save the graph as a jgum string (see |
|
The compelled arcs are drawn with the color of the key |
|