loadMRF

pyagrum.loadMRF(filename, listeners=None, verbose=False)

load a MRF from a file with optional listeners and arguments

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

  • listeners (list[Object]) – list of functions to execute

  • verbose (bool) – whether to print or not warning messages

Returns:

a MRF from a file using one of the pyagrum.availableMRFExts suffixes.

Return type:

pyagrum.MarkovRandomField

Raises:

Notes

Listeners could be added in order to monitor its loading.

pkl suffix is used to load a pickled MRF. In this case, options are ignored.

jgum/bgum suffixes use the native aGrUM JSON/binary format and also ignore listeners.

Example

import pyagrum as gum

gum.saveMRF(gum.fastMRF("A--B;B--C"), "model.uai")
mrf = gum.loadMRF("model.uai")
mrf.size()
# 3
len(mrf.factors())
# 2

# a listener is called with the progress of the loading (in %), then with 200 once the MRF is loaded
progress = []
mrf = gum.loadMRF("model.uai", listeners=[progress.append])
progress[:3], progress[-2:]
# ([1, 2, 3], [100, 200])