XDSLWriter#
- class pgmpy.readwrite.XDSLWriter(model, network_id='MyNetwork', num_samples='0', disc_samples='0', encoding='utf-8')[source]#
Bases:
objectInitialise a XDSL writer object to export pgmpy models to XDSL file format[1] used by GeNIe[2].
- Parameters:
- model: pgmpy.models.DiscreteBayesianNetwork instance.
The model to write to the file.
- network_id: str (default: “MyNetwork”)
Name/id of the network
- num_samples: int (default: 0)
Number of samples used for continuous variables
- disc_samples: int (default: 0)
Number of samples used for discrete variables
- encoding: str (optional, default=’utf-8’)
Encoding for text data
Examples
>>> from pgmpy.readwrite import XDSLWriter >>> from pgmpy.example_models import load_model >>> asia = load_model("bnlearn/asia") >>> writer = XDSLWriter(asia) >>> writer.write("asia.xdsl")
- get_variables()[source]#
Add variables and their XML elements/representation to XDSL
Examples
>>> writer = XDSLWriter(model) >>> writer.get_variables() {'asia': <Element 'cpt' at 0x000001DC6BFA1350>, 'tub': <Element 'cpt' at 0x000001DC6BFA35B0>, 'smoke': <Element 'cpt' at 0x000001DC6BFA3560>, 'lung': <Element 'cpt' at 0x000001DC6BFA12B0>, 'bronc': <Element 'cpt' at 0x000001DC6BFA1260>, 'either': <Element 'cpt' at 0x000001DC6BFA3510>, 'xray': <Element 'cpt' at 0x000001DC6BFA34C0>, 'dysp': <Element 'cpt' at 0x000001DC6BFA1210>}
- write(filename=None)[source]#
Write the xdsl data into the file.
- Parameters:
- filename: Name (path) of the file.
Examples
>>> from pgmpy.readwrite import XDSLWriter >>> from pgmpy.example_models import load_model >>> model = load_model("bnlearn/asia") >>> writer = XDSLWriter(model) >>> writer.write("asia.xdsl")