BIFWriter#

class pgmpy.readwrite.BIFWriter(model, round_values=None)[source]#

Bases: object

Initialise a BIFWriter Object

Parameters:
model: DiscreteBayesianNetwork Instance
round_values: int (default: None)

Round the probability values to round_values decimals. If None, keeps all decimal points.

Examples

>>> from pgmpy.readwrite import BIFWriter
>>> from pgmpy.example_models import load_model
>>> asia = load_model("bnlearn/asia")
>>> writer = BIFWriter(asia)
>>> writer
<writer_BIF.BIFWriter at 0x7f05e5ea27b8>
>>> writer.write("asia.bif")
BIF_templates()[source]#

Create template for writing in BIF format

get_cpds()[source]#

Adds tables to BIF

Returns:
dict: dict of type {variable: array}
get_parents()[source]#

Add the parents to BIF

Returns:
dict: dict of type {variable: a list of parents}
get_properties()[source]#

Add property to variables in BIF

Returns:
dict: dict of type {variable: list of properties }
get_states()[source]#

Add states to variable of BIF, handling commas in state names by replacing them with underscores.

Returns:
dict: dict of type {variable: a list of states}
get_variables()[source]#

Add variables to BIF

Returns:
list: a list containing names of variable
write(filename)[source]#

Writes the BIF data into a file

Parameters:
filenameName of the file
write_bif(filename)[source]#