saveMRF

pyagrum.saveMRF(mn, filename)

save a MRF into a file using the format corresponding to one of the pyagrum.availableMRFExts suffixes.

Parameters:
Raises:

pyagrum.InvalidArgument – If the extension is unknown.

Return type:

None

Notes

pkl suffix is used to save a MRF using pickle.

jgum/bgum suffixes use the native aGrUM JSON/binary format.

Warning

In the .jgum, .bgum and .pkl files, a variable whose name needs quotes (see pyagrum.quoteFastName) is written with a quoted name ('X-ray'[3]): pyAgrum 3.3.2 or older reads it with the quotes in the name.

A variable which the fast syntax does not read back exactly (the labels {10|9} of a pyagrum.LabelizedVariable, a description…) is written as a JSON object in the .jgum, .bgum and .pkl files: the file is then of version 2.0 of the GUM format, which pyAgrum 3.4 or older cannot read.

Example

import pyagrum as gum

mrf = gum.fastMRF("A--B--C")
gum.saveMRF(mrf, "model.uai")
gum.loadMRF("model.uai").factors()
# [{0, 1, 2}]