UAIReader#
- class pgmpy.readwrite.UAIReader(path=None, string=None)[source]#
Bases:
objectInitialize an instance of UAI reader class
- Parameters:
- pathfile or str
Path of the file containing UAI information.
- stringstr
String containing UAI information.
Examples
>>> from pgmpy.readwrite import UAIReader >>> reader = UAIReader("TestUai.uai") >>> model = reader.get_model()
- get_domain()[source]#
Returns the dictionary of variables with keys as variable name and values as domain of the variables.
- Returns:
- dict: dictionary containing variables and their domains
Examples
>>> from pgmpy.readwrite import UAIReader >>> reader = UAIReader("TestUAI.uai") >>> reader.get_domain() {'var_0': '2', 'var_1': '2', 'var_2': '3'}
- get_edges()[source]#
Returns the edges of the network.
- Returns:
- set: set containing the edges of the network
Examples
>>> from pgmpy.readwrite import UAIReader >>> reader = UAIReader("TestUAI.uai") >>> reader.get_edges() {('var_0', 'var_1'), ('var_0', 'var_2'), ('var_1', 'var_2')}
- get_model()[source]#
Returns an instance of Bayesian Model or Markov Model. Variables are in the pattern var_0, var_1, var_2 where var_0 is 0th index variable, var_1 is 1st index variable.
Examples
>>> from pgmpy.readwrite import UAIReader >>> reader = UAIReader("TestUAI.uai") >>> reader.get_model()
- get_network_type()[source]#
Returns the type of network defined by the file.
- Returns:
- stringstr
String containing network type.
Examples
>>> from pgmpy.readwrite import UAIReader >>> reader = UAIReader("TestUAI.uai") >>> reader.get_network_type() 'MARKOV'
- get_tables()[source]#
Returns list of tuple of child variable and CPD in case of Bayesian and list of tuple of scope of variables and values in case of Markov.
- Returns:
- listlist of tuples of child variable and values in Bayesian
list of tuples of scope of variables and values in case of Markov.
Examples
>>> from pgmpy.readwrite import UAIReader >>> reader = UAIReader("TestUAI.uai") >>> reader.get_tables() [(['var_0', 'var_1'], ['4.000', '2.400', '1.000', '0.000']), (['var_0', 'var_1', 'var_2'], ['2.2500', '3.2500', '3.7500', '0.0000', '0.0000', '10.0000', '1.8750', '4.0000', '3.3330', '2.0000', '2.0000', '3.4000'])]
- get_variables()[source]#
Returns a list of variables. Each variable is represented by an index of list. For example if the no of variables are 4 then the list will be [var_0, var_1, var_2, var_3]
- Returns:
- list: list of variables
Examples
>>> from pgmpy.readwrite import UAIReader >>> reader = UAIReader("TestUAI.uai") >>> reader.get_variables() ['var_0', 'var_1', 'var_2']