NETReader#

class pgmpy.readwrite.NETReader(path=None, string=None, include_properties=False, defaultName='bn_model')[source]#

Bases: object

Initializes a NETReader object.

Parameters:
pathfile or str

File of net data

stringstr

String of net data

include_properties: boolean

If True, gets the properties tag from the file and stores in graph properties.

defaultname: int (default: “bn_model”)

Default name for the network if a network name is not available in the net file.

Examples

# asia.net file is present at # https://www.bnlearn.com/bnrepository/discrete-small.html#asia >>> from pgmpy.readwrite import NETReader >>> reader = NETReader(“asia.net”) >>> reader <pgmpy.readwrite.NET.NETReader at 0x7feac645c640> >>> model = reader.get_model()

get_edges()[source]#

Returns the edges of the network

get_model(state_name_type=<class 'str'>)[source]#

Returns the Bayesian Model read from the file/str.

Parameters:
state_name_type: int, str or bool (default: str)

The data type to which to convert the state names of the variables.

get_network_name()[source]#

Returns the name of the network. Returns false if no network name is available

get_parents()[source]#

Returns the parents of the variables present in the network

get_probability_grammar()[source]#

A method that returns probability grammar

get_property()[source]#

Returns the property of the variable

get_states()[source]#

Returns the states of each variable in the network

get_values()[source]#

Returns the CPD of the variables present in the network

get_variable_grammar()[source]#

A method that returns variable grammar

get_variables()[source]#

Returns list of variables of the network