XMLBIFReader#
- class pgmpy.readwrite.XMLBIFReader(path=None, string=None)[source]#
Bases:
objectInitialisation of XMLBIFReader object.
- Parameters:
- pathfile or str
File of XMLBIF data File of XMLBIF data
- stringstr
String of XMLBIF data
Examples
>>> # xmlbif_test.xml is the file present in >>> # http://www.cs.cmu.edu/~fgcozman/Research/InterchangeFormat/ >>> from pgmpy.readwrite import XMLBIFReader >>> reader = XMLBIFReader("xmlbif_test.xml") >>> model = reader.get_model()
- get_edges()[source]#
Returns the edges of the network
Examples
>>> reader = XMLBIF.XMLBIFReader("xmlbif_test.xml") >>> reader.get_edges() [['family-out', 'light-on'], ['family-out', 'dog-out'], ['bowel-problem', 'dog-out'], ['dog-out', 'hear-bark']]
- get_model(state_name_type=<class 'str'>)[source]#
Returns a Bayesian Network instance from the file/string.
- Parameters:
- state_name_type: int, str, or bool (default: str)
The data type to which to convert the state names of the variables.
- Returns:
- DiscreteBayesianNetwork instance: The read model.
Examples
>>> from pgmpy.readwrite import XMLBIFReader >>> reader = XMLBIFReader("xmlbif_test.xml") >>> model = reader.get_model()
- get_parents()[source]#
Returns the parents of the variables present in the network
Examples
>>> reader = XMLBIF.XMLBIFReader("xmlbif_test.xml") >>> reader.get_parents() {'bowel-problem': [], 'dog-out': ['family-out', 'bowel-problem'], 'family-out': [], 'hear-bark': ['dog-out'], 'light-on': ['family-out']}
- get_property()[source]#
Returns the property of the variable
Examples
>>> reader = XMLBIF.XMLBIFReader("xmlbif_test.xml") >>> reader.get_property() {'bowel-problem': ['position = (190, 69)'], 'dog-out': ['position = (155, 165)'], 'family-out': ['position = (112, 69)'], 'hear-bark': ['position = (154, 241)'], 'light-on': ['position = (73, 165)']}
- get_states()[source]#
Returns the states of variables present in the network
Examples
>>> reader = XMLBIF.XMLBIFReader("xmlbif_test.xml") >>> reader.get_states() {'bowel-problem': ['true', 'false'], 'dog-out': ['true', 'false'], 'family-out': ['true', 'false'], 'hear-bark': ['true', 'false'], 'light-on': ['true', 'false']}
- get_values()[source]#
Returns the CPD of the variables present in the network
Examples
>>> reader = XMLBIF.XMLBIFReader("xmlbif_test.xml") >>> reader.get_values() {'bowel-problem': array([[ 0.01], [ 0.99]]), 'dog-out': array([[ 0.99, 0.01, 0.97, 0.03], [ 0.9 , 0.1 , 0.3 , 0.7 ]]), 'family-out': array([[ 0.15], [ 0.85]]), 'hear-bark': array([[ 0.7 , 0.3 ], [ 0.01, 0.99]]), 'light-on': array([[ 0.6 , 0.4 ], [ 0.05, 0.95]])}