UAIWriter#
- class pgmpy.readwrite.UAIWriter(model, round_values=None)[source]#
Bases:
objectInitialize an instance of UAI writer class
- Parameters:
- model: A Bayesian or Markov model
The model to write
- round_values: int (default: None)
The number to decimals to which to round the probability values. If None, keeps all decimals points.
Examples
>>> from pgmpy.readwrite import UAIWriter >>> from pgmpy.example_models import load_model >>> model = load_model("bnlearn/asia") >>> writer = UAIWriter(model) >>> writer.write("asia.uai")
- get_domain()[source]#
Adds domain of each variable to the network.
Examples
>>> from pgmpy.readwrite import UAIWriter >>> from pgmpy.example_models import load_model >>> model = load_model("bnlearn/asia") >>> writer = UAIWriter(model) >>> writer.get_domain() {'asia': '2', 'bronc': '2', 'dysp': '2', 'either': '2', 'lung': '2', 'smoke': '2', 'tub': '2', 'xray': '2'}
- get_functions()[source]#
Adds functions to the network.
Examples ——-_ >>> from pgmpy.readwrite import UAIWriter >>> from pgmpy.example_models import load_model >>> model = load_model(“bnlearn/asia”) >>> writer = UAIWriter(model) >>> writer.get_functions() # doctest: +NORMALIZE_WHITESPACE [[‘0’], [‘5’, ‘1’], [‘3’, ‘1’, ‘2’], [‘6’, ‘4’, ‘3’], [‘5’, ‘4’], [‘5’], [‘0’, ‘6’], [‘3’, ‘7’]]
- get_nodes()[source]#
Adds variables to the network.
Examples
>>> from pgmpy.readwrite import UAIWriter >>> from pgmpy.example_models import load_model >>> model = load_model("bnlearn/asia") >>> writer = UAIWriter(model) >>> writer.get_nodes() '8'
- get_tables()[source]#
Adds tables to the network.
Examples
>>> from pgmpy.readwrite import UAIWriter >>> from pgmpy.example_models import load_model >>> model = load_model("bnlearn/asia") >>> writer = UAIWriter(model) >>> writer.get_tables() [['0.01', '0.99'], ['0.6', '0.3', '0.4', '0.7'], ['0.9', '0.8', '0.7', '0.1', '0.1', '0.2', '0.3', '0.9'], ['1.0', '1.0', '1.0', '0.0', '0.0', '0.0', '0.0', '1.0'], ['0.1', '0.01', '0.9', '0.99'], ['0.5', '0.5'], ['0.05', '0.01', '0.95', '0.99'], ['0.98', '0.05', '0.02', '0.95']]