Markov random field

a Markov random field as an unoriented graph and as a factor graph

A Markov random field is an undirected probabilistic graphical model. It represents a joint distribution over a set of random variables. In pyAgrum, the variables are (for now) only discrete.

A Markov random field uses a undirected graph to represent conditional independence in the joint distribution. These conditional independences allow to factorize the joint distribution, thereby allowing to compactly represent very large ones.

\[P(X_1,\cdots,X_n)\propto\prod_{i=1}^{n_c} \phi_i(C_i)\]

Where the \(\phi_i\) are tensors over the \(n_c\) cliques of the undirected graph.

Moreover, inference algorithms can also use this graph to speed up the computations.

Note

Markov Random Field are also called Markov Network. After tag 1.5.2, pyAgrum uses the terminology Markov Random Field.

Tutorial

Input / Output

Markov random fields can be saved and loaded using the native JGUM / BGUM Format Reference (recommended) or the UAI format.

import pyagrum as gum

mrf = gum.fastMRF("A--B--C;D--A")
gum.saveMRF(mrf, "model.jgum")   # jgum (JSON)
gum.saveMRF(mrf, "model.bgum")   # bgum (binary)
mrf2 = gum.loadMRF("model.jgum")

Reference