MarkovRandomField.saveGUM

MarkovRandomField.saveGUM(name, binary=None, indent=None)

Save the Markov random field as a .jgum (text) or .bgum (binary) file.

Parameters:
  • name (str) – the name of the file

  • binary (bool, optional) – True for the msgpack-based .bgum binary format, False for the JSON-based .jgum text format. By default, the format is given by the extension of name (binary for an unknown extension).

  • indent (int, optional) – JSON indentation for the .jgum text format (ignored for the binary format): -1 for the most compact output, N>=0 to pretty-print with N spaces. Defaults to pyagrum.config["core","jgumIndent"].

Raises:

pyagrum.InvalidArgument – if binary contradicts the extension (.jgum or .bgum) of name

Return type:

None

Example

import pyagrum as gum

mrf = gum.fastMRF("A--B;B--C")
mrf.saveGUM("model.jgum")
gum.loadMRF("model.jgum").hasSameStructure(mrf)
# True

Class

MarkovRandomField