NETWriter#

class pgmpy.readwrite.NETWriter(model)[source]#

Bases: object

Base class for writing network file in net format

Parameters:
model: DiscreteBayesianNetwork Instance

Examples

>>> from pgmpy.readwrite import NETWriter
>>> from pgmpy.example_models import load_model
>>> asia = load_model("bnlearn/asia")
>>> writer = NETWriter(asia)
>>> writer
<pgmpy.readwrite.NET.NETWriter at 0x7feac652c2b0>
>>> writer.write("asia.net")
NET_templates()[source]#

Create template for writing in NET format

get_cpds()[source]#

Adds tables to NET

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

Add the parents to NET

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

Add property to variables in NET

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

Add states to variable of NET

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

Add variables to NET

Returns:
list: a list containing names of variable
net_cpd(var_name)[source]#

Util function for turning pgmpy CPT values into CPT format of .net files Inputs ——- var_name: string, name of the variable

Returns:
string: CPT format of .net files
write(filename)[source]#

Writes the NET data into a file

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