Reading and Writing from files

BIF

class pgmpy.readwrite.BIF.BIFReader(path=None, string=None)[source]

Base class for reading network file in bif format

get_edges()[source]

Returns the edges of the network

get_model()[source]

Returns the fitted bayesian model

get_network_name()[source]

Retruns the name of the network

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 variables present 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

class pgmpy.readwrite.BIF.BIFWriter(model)[source]

Base class for writing BIF network file format

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

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_bif(filename)[source]

Writes the BIF data into a file

Parameters:filename : Name of the file

PomdpX

ProbModelXML

For the student example the ProbModelXML file should be:

<?xml version=“1.0” encoding=“UTF-8”?> <ProbModelXML formatVersion=“1.0”>

<ProbNet type=”BayesianNetwork”>

<AdditionalConstraints /> <Comment>

Student example model from Probabilistic Graphical Models: Principles and Techniques by Daphne Koller

</Comment> <Language>

English

</Language> <AdditionalProperties /> <Variables>

<Variable name=”intelligence” type=”FiniteState” role=”Chance”>

<Comment /> <Coordinates /> <AdditionalProperties /> <States>

<State name=”smart”><AdditionalProperties /></State> <State name=”dumb”><AdditionalProperties /></State>

</States>

</Variable> <Variable name=”difficulty” type=”FiniteState” role=”Chance”>

<Comment /> <Coordinates /> <AdditionalProperties /> <States>

<State name=”difficult”><AdditionalProperties /></State> <State name=”easy”><AdditionalProperties /></State>

</States>

</Variable> <Variable name=”grade” type=”FiniteState” role=”Chance”>

<Comment /> <Coordinates /> <AdditionalProperties /> <States>

<State name=”grade_A”><AdditionalProperties /></State> <State name=”grade_B”><AdditionalProperties /></State> <State name=”grade_C”><AdditionalProperties /></State>

</States>

</Variable> <Variable name=”recommendation_letter” type=”FiniteState”

role=”Chance”>

<Comment /> <Coordinates /> <AdditionalProperties /> <States>

<State name=”good”><AdditionalProperties /></State> <State name=”bad”><AdditionalProperties /></State>

</States>

</Variable> <Variable name=”SAT” type=”FiniteState” role=”Chance”>

<Comment /> <Coordinates /> <AdditionalProperties /> <States>

<State name=”high”><AdditionalProperties /></State> <State name=”low”><AdditionalProperties /></State>

</States>

</Variable>

</Variables> <Links>

<Link var1=”difficulty” var2=”grade” directed=1>
<Comment>Directed Edge from difficulty to grade</Comment> <Label>diff_to_grad</Label> <AdditionalProperties />

</Link> <Link var1=”intelligence” var2=”grade” directed=1>

<Comment>Directed Edge from intelligence to grade</Comment> <Label>intel_to_grad</Label> <AdditionalProperties />

</Link> <Link var1=”intelligence” var2=”SAT” directed=1>

<Comment>Directed Edge from intelligence to SAT</Comment> <Label>intel_to_sat</Label> <AdditionalProperties />

</Link> <Link var1=”grade” var2=”recommendation_letter” directed=1>

<Comment>Directed Edge from grade to
recommendation_letter</Comment>

<Label>grad_to_reco</Label> <AdditionalProperties />

</Link>

</Links> <Potential type=”Table” role=”ConditionalProbability” label=string>

<Comment>CPDs in the form of table</Comment> <AdditionalProperties /> <!–

There is no specification in the paper about how the tables should be represented.

–>

</Potential>

</ProbNet> <Policies /> <InferenceOptions /> <Evidence>

<EvidenceCase>
<Finding variable=string state=string stateIndex=integer
numericValue=number/>

</EvidenceCase>

</Evidence>

</ProbModelXML>

UAI

XMLBeliefNetwork

XMLBIF