MarkovRandomField.toFast
- MarkovRandomField.toFast(filename=None)
Export the Markov random field in fast syntax (the structure and the variables, not the parameters), read back by
pyagrum.fastMRF. A name is quoted if it would not be read back as is otherwise (seepyagrum.quoteFastName).- Parameters:
filename (
str, optional) – if given, a Python file which builds the model withpyagrum.fastMRFis written- Returns:
the fast description of the model (if filename is None)
- Return type:
str
Warning
A variable without factor is written alone:
pyagrum.fastMRFreads it back with a factor of its own (a chain of one variable is a factor), so the copy has one more factor.
Example
import pyagrum as gum
mrf = gum.fastMRF("A--B;B--C")
mrf.toFast()
# 'A[2]--B[2];B--C[2]'
# a name is quoted when it would not be read back as is otherwise
gum.fastMRF("'a--b'--C").toFast()
# "'a--b'[2]--C[2]"
Class