partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
ConstraintBasedEstimator.pdag_to_dag
Completes a PDAG to a DAG, without adding v-structures, if such a completion exists. If no faithful extension is possible, some fully oriented DAG that corresponds to the PDAG is returned and a warning is generated. This is a static method. Parameters ---------- pdag: DA...
pgmpy/estimators/ConstraintBasedEstimator.py
def pdag_to_dag(pdag): """Completes a PDAG to a DAG, without adding v-structures, if such a completion exists. If no faithful extension is possible, some fully oriented DAG that corresponds to the PDAG is returned and a warning is generated. This is a static method. Parameters ...
def pdag_to_dag(pdag): """Completes a PDAG to a DAG, without adding v-structures, if such a completion exists. If no faithful extension is possible, some fully oriented DAG that corresponds to the PDAG is returned and a warning is generated. This is a static method. Parameters ...
[ "Completes", "a", "PDAG", "to", "a", "DAG", "without", "adding", "v", "-", "structures", "if", "such", "a", "completion", "exists", ".", "If", "no", "faithful", "extension", "is", "possible", "some", "fully", "oriented", "DAG", "that", "corresponds", "to", ...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/ConstraintBasedEstimator.py#L235-L335
[ "def", "pdag_to_dag", "(", "pdag", ")", ":", "pdag", "=", "pdag", ".", "copy", "(", ")", "dag", "=", "DAG", "(", ")", "dag", ".", "add_nodes_from", "(", "pdag", ".", "nodes", "(", ")", ")", "# add already directed edges of pdag to dag", "for", "X", ",", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ConstraintBasedEstimator.model_to_pdag
Construct the DAG pattern (representing the I-equivalence class) for a given DAG. This is the "inverse" to pdag_to_dag.
pgmpy/estimators/ConstraintBasedEstimator.py
def model_to_pdag(model): """Construct the DAG pattern (representing the I-equivalence class) for a given DAG. This is the "inverse" to pdag_to_dag. """ if not isinstance(model, DAG): raise TypeError("model: Expected DAG instance, " + "got type {m...
def model_to_pdag(model): """Construct the DAG pattern (representing the I-equivalence class) for a given DAG. This is the "inverse" to pdag_to_dag. """ if not isinstance(model, DAG): raise TypeError("model: Expected DAG instance, " + "got type {m...
[ "Construct", "the", "DAG", "pattern", "(", "representing", "the", "I", "-", "equivalence", "class", ")", "for", "a", "given", "DAG", ".", "This", "is", "the", "inverse", "to", "pdag_to_dag", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/ConstraintBasedEstimator.py#L338-L352
[ "def", "model_to_pdag", "(", "model", ")", ":", "if", "not", "isinstance", "(", "model", ",", "DAG", ")", ":", "raise", "TypeError", "(", "\"model: Expected DAG instance, \"", "+", "\"got type {model_type}\"", ".", "format", "(", "model_type", "=", "type", "(", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ConstraintBasedEstimator.skeleton_to_pdag
Orients the edges of a graph skeleton based on information from `separating_sets` to form a DAG pattern (DAG). Parameters ---------- skel: UndirectedGraph An undirected graph skeleton as e.g. produced by the estimate_skeleton method. separating_sets: dic...
pgmpy/estimators/ConstraintBasedEstimator.py
def skeleton_to_pdag(skel, separating_sets): """Orients the edges of a graph skeleton based on information from `separating_sets` to form a DAG pattern (DAG). Parameters ---------- skel: UndirectedGraph An undirected graph skeleton as e.g. produced by the ...
def skeleton_to_pdag(skel, separating_sets): """Orients the edges of a graph skeleton based on information from `separating_sets` to form a DAG pattern (DAG). Parameters ---------- skel: UndirectedGraph An undirected graph skeleton as e.g. produced by the ...
[ "Orients", "the", "edges", "of", "a", "graph", "skeleton", "based", "on", "information", "from", "separating_sets", "to", "form", "a", "DAG", "pattern", "(", "DAG", ")", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/ConstraintBasedEstimator.py#L355-L441
[ "def", "skeleton_to_pdag", "(", "skel", ",", "separating_sets", ")", ":", "pdag", "=", "skel", ".", "to_directed", "(", ")", "node_pairs", "=", "combinations", "(", "pdag", ".", "nodes", "(", ")", ",", "2", ")", "# 1) for each X-Z-Y, if Z not in the separating s...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
ConstraintBasedEstimator.build_skeleton
Estimates a graph skeleton (UndirectedGraph) from a set of independencies using (the first part of) the PC algorithm. The independencies can either be provided as an instance of the `Independencies`-class or by passing a decision function that decides any conditional independency assertion. ...
pgmpy/estimators/ConstraintBasedEstimator.py
def build_skeleton(nodes, independencies): """Estimates a graph skeleton (UndirectedGraph) from a set of independencies using (the first part of) the PC algorithm. The independencies can either be provided as an instance of the `Independencies`-class or by passing a decision function tha...
def build_skeleton(nodes, independencies): """Estimates a graph skeleton (UndirectedGraph) from a set of independencies using (the first part of) the PC algorithm. The independencies can either be provided as an instance of the `Independencies`-class or by passing a decision function tha...
[ "Estimates", "a", "graph", "skeleton", "(", "UndirectedGraph", ")", "from", "a", "set", "of", "independencies", "using", "(", "the", "first", "part", "of", ")", "the", "PC", "algorithm", ".", "The", "independencies", "can", "either", "be", "provided", "as", ...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/ConstraintBasedEstimator.py#L444-L534
[ "def", "build_skeleton", "(", "nodes", ",", "independencies", ")", ":", "nodes", "=", "list", "(", "nodes", ")", "if", "isinstance", "(", "independencies", ",", "Independencies", ")", ":", "def", "is_independent", "(", "X", ",", "Y", ",", "Zs", ")", ":",...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFReader.get_variable_grammar
A method that returns variable grammar
pgmpy/readwrite/BIF.py
def get_variable_grammar(self): """ A method that returns variable grammar """ # Defining a expression for valid word word_expr = Word(alphanums + '_' + '-') word_expr2 = Word(initChars=printables, excludeChars=['{', '}', ',', ' ']) name_expr = Suppress('variable...
def get_variable_grammar(self): """ A method that returns variable grammar """ # Defining a expression for valid word word_expr = Word(alphanums + '_' + '-') word_expr2 = Word(initChars=printables, excludeChars=['{', '}', ',', ' ']) name_expr = Suppress('variable...
[ "A", "method", "that", "returns", "variable", "grammar" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L69-L85
[ "def", "get_variable_grammar", "(", "self", ")", ":", "# Defining a expression for valid word", "word_expr", "=", "Word", "(", "alphanums", "+", "'_'", "+", "'-'", ")", "word_expr2", "=", "Word", "(", "initChars", "=", "printables", ",", "excludeChars", "=", "["...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFReader.get_probability_grammar
A method that returns probability grammar
pgmpy/readwrite/BIF.py
def get_probability_grammar(self): """ A method that returns probability grammar """ # Creating valid word expression for probability, it is of the format # wor1 | var2 , var3 or var1 var2 var3 or simply var word_expr = Word(alphanums + '-' + '_') + Suppress(Optional("|")...
def get_probability_grammar(self): """ A method that returns probability grammar """ # Creating valid word expression for probability, it is of the format # wor1 | var2 , var3 or var1 var2 var3 or simply var word_expr = Word(alphanums + '-' + '_') + Suppress(Optional("|")...
[ "A", "method", "that", "returns", "probability", "grammar" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L87-L103
[ "def", "get_probability_grammar", "(", "self", ")", ":", "# Creating valid word expression for probability, it is of the format", "# wor1 | var2 , var3 or var1 var2 var3 or simply var", "word_expr", "=", "Word", "(", "alphanums", "+", "'-'", "+", "'_'", ")", "+", "Suppress", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFReader.get_network_name
Retruns the name of the network Example --------------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIF.BifReader("bif_test.bif") >>> reader.network_name() 'Dog-Problem'
pgmpy/readwrite/BIF.py
def get_network_name(self): """ Retruns the name of the network Example --------------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIF.BifReader("bif_test.bif") >>> reader.network_name() 'Dog-Problem' """ start = self.network.f...
def get_network_name(self): """ Retruns the name of the network Example --------------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIF.BifReader("bif_test.bif") >>> reader.network_name() 'Dog-Problem' """ start = self.network.f...
[ "Retruns", "the", "name", "of", "the", "network" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L117-L134
[ "def", "get_network_name", "(", "self", ")", ":", "start", "=", "self", ".", "network", ".", "find", "(", "'network'", ")", "end", "=", "self", ".", "network", ".", "find", "(", "'}\\n'", ",", "start", ")", "# Creating a network attribute", "network_attribut...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFReader.get_variables
Returns list of variables of the network Example ------------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_variables() ['light-on','bowel_problem','dog-out','hear-bark','family-out']
pgmpy/readwrite/BIF.py
def get_variables(self): """ Returns list of variables of the network Example ------------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_variables() ['light-on','bowel_problem','dog-out','hear-bark','fami...
def get_variables(self): """ Returns list of variables of the network Example ------------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_variables() ['light-on','bowel_problem','dog-out','hear-bark','fami...
[ "Returns", "list", "of", "variables", "of", "the", "network" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L136-L152
[ "def", "get_variables", "(", "self", ")", ":", "variable_names", "=", "[", "]", "for", "block", "in", "self", ".", "variable_block", "(", ")", ":", "name", "=", "self", ".", "name_expr", ".", "searchString", "(", "block", ")", "[", "0", "]", "[", "0"...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFReader.get_states
Returns the states of variables present in the network Example ----------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_states() {'bowel-problem': ['true','false'], 'dog-out': ['true','false'], 'family-ou...
pgmpy/readwrite/BIF.py
def get_states(self): """ Returns the states of variables present in the network Example ----------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_states() {'bowel-problem': ['true','false'], 'dog-...
def get_states(self): """ Returns the states of variables present in the network Example ----------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_states() {'bowel-problem': ['true','false'], 'dog-...
[ "Returns", "the", "states", "of", "variables", "present", "in", "the", "network" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L154-L174
[ "def", "get_states", "(", "self", ")", ":", "variable_states", "=", "{", "}", "for", "block", "in", "self", ".", "variable_block", "(", ")", ":", "name", "=", "self", ".", "name_expr", ".", "searchString", "(", "block", ")", "[", "0", "]", "[", "0", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFReader.get_property
Returns the property of the variable Example ------------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_property() {'bowel-problem': ['position = (335, 99)'], 'dog-out': ['position = (300, 195)'], 'family...
pgmpy/readwrite/BIF.py
def get_property(self): """ Returns the property of the variable Example ------------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_property() {'bowel-problem': ['position = (335, 99)'], 'dog-out'...
def get_property(self): """ Returns the property of the variable Example ------------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_property() {'bowel-problem': ['position = (335, 99)'], 'dog-out'...
[ "Returns", "the", "property", "of", "the", "variable" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L176-L196
[ "def", "get_property", "(", "self", ")", ":", "variable_properties", "=", "{", "}", "for", "block", "in", "self", ".", "variable_block", "(", ")", ":", "name", "=", "self", ".", "name_expr", ".", "searchString", "(", "block", ")", "[", "0", "]", "[", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFReader.get_parents
Returns the parents of the variables present in the network Example -------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_parents() {'bowel-problem': [], 'dog-out': ['family-out', 'bowel-problem'], 'famil...
pgmpy/readwrite/BIF.py
def get_parents(self): """ Returns the parents of the variables present in the network Example -------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_parents() {'bowel-problem': [], 'dog-out': ['fa...
def get_parents(self): """ Returns the parents of the variables present in the network Example -------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_parents() {'bowel-problem': [], 'dog-out': ['fa...
[ "Returns", "the", "parents", "of", "the", "variables", "present", "in", "the", "network" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L198-L217
[ "def", "get_parents", "(", "self", ")", ":", "variable_parents", "=", "{", "}", "for", "block", "in", "self", ".", "probability_block", "(", ")", ":", "names", "=", "self", ".", "probability_expr", ".", "searchString", "(", "block", ".", "split", "(", "'...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFReader.get_values
Returns the CPD of the variables present in the network Example -------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_values() {'bowel-problem': np.array([[0.01], [0.99]]), 'do...
pgmpy/readwrite/BIF.py
def get_values(self): """ Returns the CPD of the variables present in the network Example -------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_values() {'bowel-problem': np.array([[0.01], ...
def get_values(self): """ Returns the CPD of the variables present in the network Example -------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_values() {'bowel-problem': np.array([[0.01], ...
[ "Returns", "the", "CPD", "of", "the", "variables", "present", "in", "the", "network" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L219-L260
[ "def", "get_values", "(", "self", ")", ":", "variable_cpds", "=", "{", "}", "for", "block", "in", "self", ".", "probability_block", "(", ")", ":", "names", "=", "self", ".", "probability_expr", ".", "searchString", "(", "block", ")", "var_name", ",", "pa...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFReader.get_edges
Returns the edges of the network Example -------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_edges() [['family-out', 'light-on'], ['family-out', 'dog-out'], ['bowel-problem', 'dog-out'], ['do...
pgmpy/readwrite/BIF.py
def get_edges(self): """ Returns the edges of the network Example -------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_edges() [['family-out', 'light-on'], ['family-out', 'dog-out'], ['...
def get_edges(self): """ Returns the edges of the network Example -------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_edges() [['family-out', 'light-on'], ['family-out', 'dog-out'], ['...
[ "Returns", "the", "edges", "of", "the", "network" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L262-L278
[ "def", "get_edges", "(", "self", ")", ":", "edges", "=", "[", "[", "value", ",", "key", "]", "for", "key", "in", "self", ".", "variable_parents", ".", "keys", "(", ")", "for", "value", "in", "self", ".", "variable_parents", "[", "key", "]", "]", "r...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFReader.get_model
Returns the fitted bayesian model Example ---------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_model() <pgmpy.models.BayesianModel.BayesianModel object at 0x7f20af154320>
pgmpy/readwrite/BIF.py
def get_model(self): """ Returns the fitted bayesian model Example ---------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_model() <pgmpy.models.BayesianModel.BayesianModel object at 0x7f20af154320> ...
def get_model(self): """ Returns the fitted bayesian model Example ---------- >>> from pgmpy.readwrite import BIFReader >>> reader = BIFReader("bif_test.bif") >>> reader.get_model() <pgmpy.models.BayesianModel.BayesianModel object at 0x7f20af154320> ...
[ "Returns", "the", "fitted", "bayesian", "model" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L280-L315
[ "def", "get_model", "(", "self", ")", ":", "try", ":", "model", "=", "BayesianModel", "(", ")", "model", ".", "add_nodes_from", "(", "self", ".", "variable_names", ")", "model", ".", "add_edges_from", "(", "self", ".", "variable_edges", ")", "model", ".", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFWriter.BIF_templates
Create template for writing in BIF format
pgmpy/readwrite/BIF.py
def BIF_templates(self): """ Create template for writing in BIF format """ network_template = Template('network $name {\n}\n') # property tag may or may not be present in model,and since no of properties # can be more than one , will replace them accoriding to format othe...
def BIF_templates(self): """ Create template for writing in BIF format """ network_template = Template('network $name {\n}\n') # property tag may or may not be present in model,and since no of properties # can be more than one , will replace them accoriding to format othe...
[ "Create", "template", "for", "writing", "in", "BIF", "format" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L351-L366
[ "def", "BIF_templates", "(", "self", ")", ":", "network_template", "=", "Template", "(", "'network $name {\\n}\\n'", ")", "# property tag may or may not be present in model,and since no of properties", "# can be more than one , will replace them accoriding to format otherwise null", "var...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFWriter.get_states
Add states to variable of BIF Returns ------- dict: dict of type {variable: a list of states} Example ------- >>> from pgmpy.readwrite import BIFReader, BIFWriter >>> model = BIFReader('dog-problem.bif').get_model() >>> writer = BIFWriter(model) ...
pgmpy/readwrite/BIF.py
def get_states(self): """ Add states to variable of BIF Returns ------- dict: dict of type {variable: a list of states} Example ------- >>> from pgmpy.readwrite import BIFReader, BIFWriter >>> model = BIFReader('dog-problem.bif').get_model() ...
def get_states(self): """ Add states to variable of BIF Returns ------- dict: dict of type {variable: a list of states} Example ------- >>> from pgmpy.readwrite import BIFReader, BIFWriter >>> model = BIFReader('dog-problem.bif').get_model() ...
[ "Add", "states", "to", "variable", "of", "BIF" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L421-L448
[ "def", "get_states", "(", "self", ")", ":", "variable_states", "=", "{", "}", "cpds", "=", "self", ".", "model", ".", "get_cpds", "(", ")", "for", "cpd", "in", "cpds", ":", "variable", "=", "cpd", ".", "variable", "variable_states", "[", "variable", "]...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFWriter.get_properties
Add property to variables in BIF Returns ------- dict: dict of type {variable: list of properties } Example ------- >>> from pgmpy.readwrite import BIFReader, BIFWriter >>> model = BIFReader('dog-problem.bif').get_model() >>> writer = BIFWriter(model) ...
pgmpy/readwrite/BIF.py
def get_properties(self): """ Add property to variables in BIF Returns ------- dict: dict of type {variable: list of properties } Example ------- >>> from pgmpy.readwrite import BIFReader, BIFWriter >>> model = BIFReader('dog-problem.bif').get_mo...
def get_properties(self): """ Add property to variables in BIF Returns ------- dict: dict of type {variable: list of properties } Example ------- >>> from pgmpy.readwrite import BIFReader, BIFWriter >>> model = BIFReader('dog-problem.bif').get_mo...
[ "Add", "property", "to", "variables", "in", "BIF" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L450-L478
[ "def", "get_properties", "(", "self", ")", ":", "variables", "=", "self", ".", "model", ".", "nodes", "(", ")", "property_tag", "=", "{", "}", "for", "variable", "in", "sorted", "(", "variables", ")", ":", "properties", "=", "self", ".", "model", ".", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFWriter.get_parents
Add the parents to BIF Returns ------- dict: dict of type {variable: a list of parents} Example ------- >>> from pgmpy.readwrite import BIFReader, BIFWriter >>> model = BIFReader('dog-problem.bif').get_model() >>> writer = BIFWriter(model) >>> wr...
pgmpy/readwrite/BIF.py
def get_parents(self): """ Add the parents to BIF Returns ------- dict: dict of type {variable: a list of parents} Example ------- >>> from pgmpy.readwrite import BIFReader, BIFWriter >>> model = BIFReader('dog-problem.bif').get_model() >...
def get_parents(self): """ Add the parents to BIF Returns ------- dict: dict of type {variable: a list of parents} Example ------- >>> from pgmpy.readwrite import BIFReader, BIFWriter >>> model = BIFReader('dog-problem.bif').get_model() >...
[ "Add", "the", "parents", "to", "BIF" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L480-L507
[ "def", "get_parents", "(", "self", ")", ":", "cpds", "=", "self", ".", "model", ".", "get_cpds", "(", ")", "cpds", ".", "sort", "(", "key", "=", "lambda", "x", ":", "x", ".", "variable", ")", "variable_parents", "=", "{", "}", "for", "cpd", "in", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFWriter.get_cpds
Adds tables to BIF Returns ------- dict: dict of type {variable: array} Example ------- >>> from pgmpy.readwrite import BIFReader, BIFWriter >>> model = BIFReader('dog-problem.bif').get_model() >>> writer = BIFWriter(model) >>> writer.get_cpds() ...
pgmpy/readwrite/BIF.py
def get_cpds(self): """ Adds tables to BIF Returns ------- dict: dict of type {variable: array} Example ------- >>> from pgmpy.readwrite import BIFReader, BIFWriter >>> model = BIFReader('dog-problem.bif').get_model() >>> writer = BIFWrit...
def get_cpds(self): """ Adds tables to BIF Returns ------- dict: dict of type {variable: array} Example ------- >>> from pgmpy.readwrite import BIFReader, BIFWriter >>> model = BIFReader('dog-problem.bif').get_model() >>> writer = BIFWrit...
[ "Adds", "tables", "to", "BIF" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L509-L533
[ "def", "get_cpds", "(", "self", ")", ":", "cpds", "=", "self", ".", "model", ".", "get_cpds", "(", ")", "tables", "=", "{", "}", "for", "cpd", "in", "cpds", ":", "tables", "[", "cpd", ".", "variable", "]", "=", "cpd", ".", "values", ".", "ravel",...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BIFWriter.write_bif
Writes the BIF data into a file Parameters ---------- filename : Name of the file Example ------- >>> from pgmpy.readwrite import BIFReader, BIFWriter >>> model = BIFReader('dog-problem.bif').get_model() >>> writer = BIFWriter(model) >>> writer.w...
pgmpy/readwrite/BIF.py
def write_bif(self, filename): """ Writes the BIF data into a file Parameters ---------- filename : Name of the file Example ------- >>> from pgmpy.readwrite import BIFReader, BIFWriter >>> model = BIFReader('dog-problem.bif').get_model() ...
def write_bif(self, filename): """ Writes the BIF data into a file Parameters ---------- filename : Name of the file Example ------- >>> from pgmpy.readwrite import BIFReader, BIFWriter >>> model = BIFReader('dog-problem.bif').get_model() ...
[ "Writes", "the", "BIF", "data", "into", "a", "file" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/BIF.py#L535-L552
[ "def", "write_bif", "(", "self", ",", "filename", ")", ":", "writer", "=", "self", ".", "__str__", "(", ")", "with", "open", "(", "filename", ",", "'w'", ")", "as", "fout", ":", "fout", ".", "write", "(", "writer", ")" ]
9381a66aba3c3871d3ccd00672b148d17d63239e
train
CanonicalDistribution.copy
Makes a copy of the factor. Returns ------- CanonicalDistribution object: Copy of the factor Examples -------- >>> from pgmpy.factors.continuous import CanonicalDistribution >>> phi = CanonicalDistribution(['X', 'Y'], np.array([[1, -1], [-1, 1]]), ...
pgmpy/factors/distributions/CanonicalDistribution.py
def copy(self): """ Makes a copy of the factor. Returns ------- CanonicalDistribution object: Copy of the factor Examples -------- >>> from pgmpy.factors.continuous import CanonicalDistribution >>> phi = CanonicalDistribution(['X', 'Y'], np.array...
def copy(self): """ Makes a copy of the factor. Returns ------- CanonicalDistribution object: Copy of the factor Examples -------- >>> from pgmpy.factors.continuous import CanonicalDistribution >>> phi = CanonicalDistribution(['X', 'Y'], np.array...
[ "Makes", "a", "copy", "of", "the", "factor", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/CanonicalDistribution.py#L116-L163
[ "def", "copy", "(", "self", ")", ":", "copy_factor", "=", "CanonicalDistribution", "(", "self", ".", "variables", ",", "self", ".", "K", ".", "copy", "(", ")", ",", "self", ".", "h", ".", "copy", "(", ")", ",", "self", ".", "g", ")", "return", "c...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
CanonicalDistribution.to_joint_gaussian
Return an equivalent Joint Gaussian Distribution. Examples -------- >>> import numpy as np >>> from pgmpy.factors.continuous import CanonicalDistribution >>> phi = CanonicalDistribution(['x1', 'x2'], np.array([[3, -2], [-2, 4]]), np.array([[5],...
pgmpy/factors/distributions/CanonicalDistribution.py
def to_joint_gaussian(self): """ Return an equivalent Joint Gaussian Distribution. Examples -------- >>> import numpy as np >>> from pgmpy.factors.continuous import CanonicalDistribution >>> phi = CanonicalDistribution(['x1', 'x2'], np.array([[3, -2], [-2, 4]]),...
def to_joint_gaussian(self): """ Return an equivalent Joint Gaussian Distribution. Examples -------- >>> import numpy as np >>> from pgmpy.factors.continuous import CanonicalDistribution >>> phi = CanonicalDistribution(['x1', 'x2'], np.array([[3, -2], [-2, 4]]),...
[ "Return", "an", "equivalent", "Joint", "Gaussian", "Distribution", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/CanonicalDistribution.py#L165-L190
[ "def", "to_joint_gaussian", "(", "self", ")", ":", "covariance", "=", "np", ".", "linalg", ".", "inv", "(", "self", ".", "K", ")", "mean", "=", "np", ".", "dot", "(", "covariance", ",", "self", ".", "h", ")", "return", "GaussianDistribution", "(", "s...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
CanonicalDistribution.reduce
Reduces the distribution to the context of the given variable values. Let C(X,Y ; K, h, g) be some canonical form over X,Y where, k = [[K_XX, K_XY], ; h = [[h_X], [K_YX, K_YY]] [h_Y]] The formula for the obtained conditional distribution for setti...
pgmpy/factors/distributions/CanonicalDistribution.py
def reduce(self, values, inplace=True): """ Reduces the distribution to the context of the given variable values. Let C(X,Y ; K, h, g) be some canonical form over X,Y where, k = [[K_XX, K_XY], ; h = [[h_X], [K_YX, K_YY]] [h_Y]] The...
def reduce(self, values, inplace=True): """ Reduces the distribution to the context of the given variable values. Let C(X,Y ; K, h, g) be some canonical form over X,Y where, k = [[K_XX, K_XY], ; h = [[h_X], [K_YX, K_YY]] [h_Y]] The...
[ "Reduces", "the", "distribution", "to", "the", "context", "of", "the", "given", "variable", "values", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/CanonicalDistribution.py#L192-L293
[ "def", "reduce", "(", "self", ",", "values", ",", "inplace", "=", "True", ")", ":", "if", "not", "isinstance", "(", "values", ",", "(", "list", ",", "tuple", ",", "np", ".", "ndarray", ")", ")", ":", "raise", "TypeError", "(", "\"variables: Expected ty...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
CanonicalDistribution.marginalize
u""" Modifies the factor with marginalized values. Let C(X,Y ; K, h, g) be some canonical form over X,Y where, k = [[K_XX, K_XY], ; h = [[h_X], [K_YX, K_YY]] [h_Y]] In this case, the result of the integration operation is a canonical ...
pgmpy/factors/distributions/CanonicalDistribution.py
def marginalize(self, variables, inplace=True): u""" Modifies the factor with marginalized values. Let C(X,Y ; K, h, g) be some canonical form over X,Y where, k = [[K_XX, K_XY], ; h = [[h_X], [K_YX, K_YY]] [h_Y]] In this case, the ...
def marginalize(self, variables, inplace=True): u""" Modifies the factor with marginalized values. Let C(X,Y ; K, h, g) be some canonical form over X,Y where, k = [[K_XX, K_XY], ; h = [[h_X], [K_YX, K_YY]] [h_Y]] In this case, the ...
[ "u", "Modifies", "the", "factor", "with", "marginalized", "values", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/CanonicalDistribution.py#L295-L391
[ "def", "marginalize", "(", "self", ",", "variables", ",", "inplace", "=", "True", ")", ":", "if", "not", "isinstance", "(", "variables", ",", "(", "list", ",", "tuple", ",", "np", ".", "ndarray", ")", ")", ":", "raise", "TypeError", "(", "\"variables: ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
CanonicalDistribution._operate
Gives the CanonicalDistribution operation (product or divide) with the other factor. The product of two canonical factors over the same scope X is simply: C(K1, h1, g1) * C(K2, h2, g2) = C(K1+K2, h1+h2, g1+g2) The division of canonical forms is defined analogously: C(...
pgmpy/factors/distributions/CanonicalDistribution.py
def _operate(self, other, operation, inplace=True): """ Gives the CanonicalDistribution operation (product or divide) with the other factor. The product of two canonical factors over the same scope X is simply: C(K1, h1, g1) * C(K2, h2, g2) = C(K1+K2, h1+h2, g1+g2) ...
def _operate(self, other, operation, inplace=True): """ Gives the CanonicalDistribution operation (product or divide) with the other factor. The product of two canonical factors over the same scope X is simply: C(K1, h1, g1) * C(K2, h2, g2) = C(K1+K2, h1+h2, g1+g2) ...
[ "Gives", "the", "CanonicalDistribution", "operation", "(", "product", "or", "divide", ")", "with", "the", "other", "factor", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/distributions/CanonicalDistribution.py#L393-L496
[ "def", "_operate", "(", "self", ",", "other", ",", "operation", ",", "inplace", "=", "True", ")", ":", "if", "not", "isinstance", "(", "other", ",", "CanonicalDistribution", ")", ":", "raise", "TypeError", "(", "\"CanonicalDistribution object can only be multiplie...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXReader.get_variables
Returns list of variables of the network Example ------- >>> reader = PomdpXReader("pomdpx.xml") >>> reader.get_variables() {'StateVar': [ {'vnamePrev': 'rover_0', 'vnameCurr': 'rover_1', 'ValueEnum': ['s0...
pgmpy/readwrite/PomdpX.py
def get_variables(self): """ Returns list of variables of the network Example ------- >>> reader = PomdpXReader("pomdpx.xml") >>> reader.get_variables() {'StateVar': [ {'vnamePrev': 'rover_0', 'vnameCurr': 'rover_1...
def get_variables(self): """ Returns list of variables of the network Example ------- >>> reader = PomdpXReader("pomdpx.xml") >>> reader.get_variables() {'StateVar': [ {'vnamePrev': 'rover_0', 'vnameCurr': 'rover_1...
[ "Returns", "list", "of", "variables", "of", "the", "network" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L86-L152
[ "def", "get_variables", "(", "self", ")", ":", "self", ".", "variables", "=", "defaultdict", "(", "list", ")", "for", "variable", "in", "self", ".", "network", ".", "findall", "(", "'Variable'", ")", ":", "_variables", "=", "defaultdict", "(", "list", ")...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXReader.get_initial_beliefs
Returns the state, action and observation variables as a dictionary in the case of table type parameter and a nested structure in case of decision diagram parameter Examples -------- >>> reader = PomdpXReader('Test_PomdpX.xml') >>> reader.get_initial_beliefs() [{...
pgmpy/readwrite/PomdpX.py
def get_initial_beliefs(self): """ Returns the state, action and observation variables as a dictionary in the case of table type parameter and a nested structure in case of decision diagram parameter Examples -------- >>> reader = PomdpXReader('Test_PomdpX.xml') ...
def get_initial_beliefs(self): """ Returns the state, action and observation variables as a dictionary in the case of table type parameter and a nested structure in case of decision diagram parameter Examples -------- >>> reader = PomdpXReader('Test_PomdpX.xml') ...
[ "Returns", "the", "state", "action", "and", "observation", "variables", "as", "a", "dictionary", "in", "the", "case", "of", "table", "type", "parameter", "and", "a", "nested", "structure", "in", "case", "of", "decision", "diagram", "parameter" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L154-L188
[ "def", "get_initial_beliefs", "(", "self", ")", ":", "initial_state_belief", "=", "[", "]", "for", "variable", "in", "self", ".", "network", ".", "findall", "(", "'InitialStateBelief'", ")", ":", "for", "var", "in", "variable", ".", "findall", "(", "'CondPro...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXReader.get_state_transition_function
Returns the transition of the state variables as nested dict in the case of table type parameter and a nested structure in case of decision diagram parameter Example -------- >>> reader = PomdpXReader('Test_PomdpX.xml') >>> reader.get_state_transition_function() ...
pgmpy/readwrite/PomdpX.py
def get_state_transition_function(self): """ Returns the transition of the state variables as nested dict in the case of table type parameter and a nested structure in case of decision diagram parameter Example -------- >>> reader = PomdpXReader('Test_PomdpX.xml'...
def get_state_transition_function(self): """ Returns the transition of the state variables as nested dict in the case of table type parameter and a nested structure in case of decision diagram parameter Example -------- >>> reader = PomdpXReader('Test_PomdpX.xml'...
[ "Returns", "the", "transition", "of", "the", "state", "variables", "as", "nested", "dict", "in", "the", "case", "of", "table", "type", "parameter", "and", "a", "nested", "structure", "in", "case", "of", "decision", "diagram", "parameter" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L190-L224
[ "def", "get_state_transition_function", "(", "self", ")", ":", "state_transition_function", "=", "[", "]", "for", "variable", "in", "self", ".", "network", ".", "findall", "(", "'StateTransitionFunction'", ")", ":", "for", "var", "in", "variable", ".", "findall"...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXReader.get_obs_function
Returns the observation function as nested dict in the case of table- type parameter and a nested structure in case of decision diagram parameter Example -------- >>> reader = PomdpXReader('Test_PomdpX.xml') >>> reader.get_obs_function() [{'Var': 'obs_sensor', ...
pgmpy/readwrite/PomdpX.py
def get_obs_function(self): """ Returns the observation function as nested dict in the case of table- type parameter and a nested structure in case of decision diagram parameter Example -------- >>> reader = PomdpXReader('Test_PomdpX.xml') >>> reader.get_...
def get_obs_function(self): """ Returns the observation function as nested dict in the case of table- type parameter and a nested structure in case of decision diagram parameter Example -------- >>> reader = PomdpXReader('Test_PomdpX.xml') >>> reader.get_...
[ "Returns", "the", "observation", "function", "as", "nested", "dict", "in", "the", "case", "of", "table", "-", "type", "parameter", "and", "a", "nested", "structure", "in", "case", "of", "decision", "diagram", "parameter" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L226-L258
[ "def", "get_obs_function", "(", "self", ")", ":", "obs_function", "=", "[", "]", "for", "variable", "in", "self", ".", "network", ".", "findall", "(", "'ObsFunction'", ")", ":", "for", "var", "in", "variable", ".", "findall", "(", "'CondProb'", ")", ":",...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXReader.get_reward_function
Returns the reward function as nested dict in the case of table- type parameter and a nested structure in case of decision diagram parameter Example -------- >>> reader = PomdpXReader('Test_PomdpX.xml') >>> reader.get_reward_function() [{'Var': 'reward_rover', ...
pgmpy/readwrite/PomdpX.py
def get_reward_function(self): """ Returns the reward function as nested dict in the case of table- type parameter and a nested structure in case of decision diagram parameter Example -------- >>> reader = PomdpXReader('Test_PomdpX.xml') >>> reader.get_re...
def get_reward_function(self): """ Returns the reward function as nested dict in the case of table- type parameter and a nested structure in case of decision diagram parameter Example -------- >>> reader = PomdpXReader('Test_PomdpX.xml') >>> reader.get_re...
[ "Returns", "the", "reward", "function", "as", "nested", "dict", "in", "the", "case", "of", "table", "-", "type", "parameter", "and", "a", "nested", "structure", "in", "case", "of", "decision", "diagram", "parameter" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L260-L292
[ "def", "get_reward_function", "(", "self", ")", ":", "reward_function", "=", "[", "]", "for", "variable", "in", "self", ".", "network", ".", "findall", "(", "'RewardFunction'", ")", ":", "for", "var", "in", "variable", ".", "findall", "(", "'Func'", ")", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXReader.get_parameter
This method supports the functional tags by providing the actual values in the function as list of dict in case of table type parameter or as nested dict in case of decision diagram
pgmpy/readwrite/PomdpX.py
def get_parameter(self, var): """ This method supports the functional tags by providing the actual values in the function as list of dict in case of table type parameter or as nested dict in case of decision diagram """ parameter = [] for parameter_tag in var.fin...
def get_parameter(self, var): """ This method supports the functional tags by providing the actual values in the function as list of dict in case of table type parameter or as nested dict in case of decision diagram """ parameter = [] for parameter_tag in var.fin...
[ "This", "method", "supports", "the", "functional", "tags", "by", "providing", "the", "actual", "values", "in", "the", "function", "as", "list", "of", "dict", "in", "case", "of", "table", "type", "parameter", "or", "as", "nested", "dict", "in", "case", "of"...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L294-L312
[ "def", "get_parameter", "(", "self", ",", "var", ")", ":", "parameter", "=", "[", "]", "for", "parameter_tag", "in", "var", ".", "findall", "(", "'Parameter'", ")", ":", "parameter_type", "=", "'TBL'", "if", "parameter_tag", ".", "get", "(", "'type'", ")...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXReader.get_parameter_tbl
This method returns parameters as list of dict in case of table type parameter
pgmpy/readwrite/PomdpX.py
def get_parameter_tbl(self, parameter): """ This method returns parameters as list of dict in case of table type parameter """ par = [] for entry in parameter.findall('Entry'): instance = defaultdict(list) instance['Instance'] = entry.find('Instanc...
def get_parameter_tbl(self, parameter): """ This method returns parameters as list of dict in case of table type parameter """ par = [] for entry in parameter.findall('Entry'): instance = defaultdict(list) instance['Instance'] = entry.find('Instanc...
[ "This", "method", "returns", "parameters", "as", "list", "of", "dict", "in", "case", "of", "table", "type", "parameter" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L314-L328
[ "def", "get_parameter_tbl", "(", "self", ",", "parameter", ")", ":", "par", "=", "[", "]", "for", "entry", "in", "parameter", ".", "findall", "(", "'Entry'", ")", ":", "instance", "=", "defaultdict", "(", "list", ")", "instance", "[", "'Instance'", "]", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXReader.get_parameter_dd
This method returns parameters as nested dicts in case of decision diagram parameter.
pgmpy/readwrite/PomdpX.py
def get_parameter_dd(self, parameter): """ This method returns parameters as nested dicts in case of decision diagram parameter. """ dag = defaultdict(list) dag_elem = parameter.find('DAG') node = dag_elem.find('Node') root = node.get('var') def g...
def get_parameter_dd(self, parameter): """ This method returns parameters as nested dicts in case of decision diagram parameter. """ dag = defaultdict(list) dag_elem = parameter.find('DAG') node = dag_elem.find('Node') root = node.get('var') def g...
[ "This", "method", "returns", "parameters", "as", "nested", "dicts", "in", "case", "of", "decision", "diagram", "parameter", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L330-L374
[ "def", "get_parameter_dd", "(", "self", ",", "parameter", ")", ":", "dag", "=", "defaultdict", "(", "list", ")", "dag_elem", "=", "parameter", ".", "find", "(", "'DAG'", ")", "node", "=", "dag_elem", ".", "find", "(", "'Node'", ")", "root", "=", "node"...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXWriter._add_value_enum
supports adding variables to the xml Parameters --------------- var: The SubElement variable tag: The SubElement tag to which enum value is to be added Return --------------- None
pgmpy/readwrite/PomdpX.py
def _add_value_enum(self, var, tag): """ supports adding variables to the xml Parameters --------------- var: The SubElement variable tag: The SubElement tag to which enum value is to be added Return --------------- None """ if va...
def _add_value_enum(self, var, tag): """ supports adding variables to the xml Parameters --------------- var: The SubElement variable tag: The SubElement tag to which enum value is to be added Return --------------- None """ if va...
[ "supports", "adding", "variables", "to", "the", "xml" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L434-L455
[ "def", "_add_value_enum", "(", "self", ",", "var", ",", "tag", ")", ":", "if", "var", "[", "'ValueEnum'", "]", "[", "0", "]", "==", "'s0'", ":", "numvalues_tag", "=", "etree", ".", "SubElement", "(", "tag", ",", "'NumValues'", ")", "numvalues_tag", "."...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXWriter.get_variables
Add variables to PomdpX Return --------------- xml containing variables tag
pgmpy/readwrite/PomdpX.py
def get_variables(self): """ Add variables to PomdpX Return --------------- xml containing variables tag """ state_variables = self.model['variables']['StateVar'] for var in state_variables: state_var_tag = etree.SubElement(self.variable, 'Sta...
def get_variables(self): """ Add variables to PomdpX Return --------------- xml containing variables tag """ state_variables = self.model['variables']['StateVar'] for var in state_variables: state_var_tag = etree.SubElement(self.variable, 'Sta...
[ "Add", "variables", "to", "PomdpX" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L457-L487
[ "def", "get_variables", "(", "self", ")", ":", "state_variables", "=", "self", ".", "model", "[", "'variables'", "]", "[", "'StateVar'", "]", "for", "var", "in", "state_variables", ":", "state_var_tag", "=", "etree", ".", "SubElement", "(", "self", ".", "v...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXWriter.add_parameter_dd
helper function for adding parameters in condition Parameters --------------- dag_tag: etree SubElement the DAG tag is contained in this subelement node_dict: dictionary the decision diagram dictionary Return --------------- N...
pgmpy/readwrite/PomdpX.py
def add_parameter_dd(self, dag_tag, node_dict): """ helper function for adding parameters in condition Parameters --------------- dag_tag: etree SubElement the DAG tag is contained in this subelement node_dict: dictionary the decision ...
def add_parameter_dd(self, dag_tag, node_dict): """ helper function for adding parameters in condition Parameters --------------- dag_tag: etree SubElement the DAG tag is contained in this subelement node_dict: dictionary the decision ...
[ "helper", "function", "for", "adding", "parameters", "in", "condition" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L489-L522
[ "def", "add_parameter_dd", "(", "self", ",", "dag_tag", ",", "node_dict", ")", ":", "if", "isinstance", "(", "node_dict", ",", "defaultdict", ")", "or", "isinstance", "(", "node_dict", ",", "dict", ")", ":", "node_tag", "=", "etree", ".", "SubElement", "("...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXWriter.add_conditions
helper function for adding probability conditions for model\ Parameters --------------- condition: dictionary contains and element of conditions list condprob: etree SubElement the tag to which condition is added Return ------...
pgmpy/readwrite/PomdpX.py
def add_conditions(self, condition, condprob): """ helper function for adding probability conditions for model\ Parameters --------------- condition: dictionary contains and element of conditions list condprob: etree SubElement ...
def add_conditions(self, condition, condprob): """ helper function for adding probability conditions for model\ Parameters --------------- condition: dictionary contains and element of conditions list condprob: etree SubElement ...
[ "helper", "function", "for", "adding", "probability", "conditions", "for", "model", "\\" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L524-L582
[ "def", "add_conditions", "(", "self", ",", "condition", ",", "condprob", ")", ":", "var_tag", "=", "etree", ".", "SubElement", "(", "condprob", ",", "'Var'", ")", "var_tag", ".", "text", "=", "condition", "[", "'Var'", "]", "parent_tag", "=", "etree", "....
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXWriter.add_initial_belief
add initial belief tag to pomdpx model Return --------------- string containing the xml for initial belief tag
pgmpy/readwrite/PomdpX.py
def add_initial_belief(self): """ add initial belief tag to pomdpx model Return --------------- string containing the xml for initial belief tag """ initial_belief = self.model['initial_state_belief'] for condition in initial_belief: condprob ...
def add_initial_belief(self): """ add initial belief tag to pomdpx model Return --------------- string containing the xml for initial belief tag """ initial_belief = self.model['initial_state_belief'] for condition in initial_belief: condprob ...
[ "add", "initial", "belief", "tag", "to", "pomdpx", "model" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L584-L596
[ "def", "add_initial_belief", "(", "self", ")", ":", "initial_belief", "=", "self", ".", "model", "[", "'initial_state_belief'", "]", "for", "condition", "in", "initial_belief", ":", "condprob", "=", "etree", ".", "SubElement", "(", "self", ".", "initial_belief",...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXWriter.add_state_transition_function
add state transition function tag to pomdpx model Return --------------- string containing the xml for state transition tag
pgmpy/readwrite/PomdpX.py
def add_state_transition_function(self): """ add state transition function tag to pomdpx model Return --------------- string containing the xml for state transition tag """ state_transition_function = self.model['state_transition_function'] for condition ...
def add_state_transition_function(self): """ add state transition function tag to pomdpx model Return --------------- string containing the xml for state transition tag """ state_transition_function = self.model['state_transition_function'] for condition ...
[ "add", "state", "transition", "function", "tag", "to", "pomdpx", "model" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L598-L610
[ "def", "add_state_transition_function", "(", "self", ")", ":", "state_transition_function", "=", "self", ".", "model", "[", "'state_transition_function'", "]", "for", "condition", "in", "state_transition_function", ":", "condprob", "=", "etree", ".", "SubElement", "("...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXWriter.add_obs_function
add observation function tag to pomdpx model Return --------------- string containing the xml for observation function tag
pgmpy/readwrite/PomdpX.py
def add_obs_function(self): """ add observation function tag to pomdpx model Return --------------- string containing the xml for observation function tag """ obs_function = self.model['obs_function'] for condition in obs_function: condprob = ...
def add_obs_function(self): """ add observation function tag to pomdpx model Return --------------- string containing the xml for observation function tag """ obs_function = self.model['obs_function'] for condition in obs_function: condprob = ...
[ "add", "observation", "function", "tag", "to", "pomdpx", "model" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L612-L624
[ "def", "add_obs_function", "(", "self", ")", ":", "obs_function", "=", "self", ".", "model", "[", "'obs_function'", "]", "for", "condition", "in", "obs_function", ":", "condprob", "=", "etree", ".", "SubElement", "(", "self", ".", "observation_function", ",", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
PomdpXWriter.add_reward_function
add reward function tag to pomdpx model Return --------------- string containing the xml for reward function tag
pgmpy/readwrite/PomdpX.py
def add_reward_function(self): """ add reward function tag to pomdpx model Return --------------- string containing the xml for reward function tag """ reward_function = self.model['reward_function'] for condition in reward_function: condprob ...
def add_reward_function(self): """ add reward function tag to pomdpx model Return --------------- string containing the xml for reward function tag """ reward_function = self.model['reward_function'] for condition in reward_function: condprob ...
[ "add", "reward", "function", "tag", "to", "pomdpx", "model" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/PomdpX.py#L626-L638
[ "def", "add_reward_function", "(", "self", ")", ":", "reward_function", "=", "self", ".", "model", "[", "'reward_function'", "]", "for", "condition", "in", "reward_function", ":", "condprob", "=", "etree", ".", "SubElement", "(", "self", ".", "reward_function", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
UAIReader.get_grammar
Returns the grammar of the UAI file.
pgmpy/readwrite/UAI.py
def get_grammar(self): """ Returns the grammar of the UAI file. """ network_name = Word(alphas).setResultsName('network_name') no_variables = Word(nums).setResultsName('no_variables') grammar = network_name + no_variables self.no_variables = int(grammar.parseStrin...
def get_grammar(self): """ Returns the grammar of the UAI file. """ network_name = Word(alphas).setResultsName('network_name') no_variables = Word(nums).setResultsName('no_variables') grammar = network_name + no_variables self.no_variables = int(grammar.parseStrin...
[ "Returns", "the", "grammar", "of", "the", "UAI", "file", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/UAI.py#L50-L78
[ "def", "get_grammar", "(", "self", ")", ":", "network_name", "=", "Word", "(", "alphas", ")", ".", "setResultsName", "(", "'network_name'", ")", "no_variables", "=", "Word", "(", "nums", ")", ".", "setResultsName", "(", "'no_variables'", ")", "grammar", "=",...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
UAIReader.get_variables
Returns a list of variables. Each variable is represented by an index of list. For example if the no of variables are 4 then the list will be [var_0, var_1, var_2, var_3] Returns ------- list: list of variables Example ------- >>> reader = UAIRea...
pgmpy/readwrite/UAI.py
def get_variables(self): """ Returns a list of variables. Each variable is represented by an index of list. For example if the no of variables are 4 then the list will be [var_0, var_1, var_2, var_3] Returns ------- list: list of variables Exampl...
def get_variables(self): """ Returns a list of variables. Each variable is represented by an index of list. For example if the no of variables are 4 then the list will be [var_0, var_1, var_2, var_3] Returns ------- list: list of variables Exampl...
[ "Returns", "a", "list", "of", "variables", ".", "Each", "variable", "is", "represented", "by", "an", "index", "of", "list", ".", "For", "example", "if", "the", "no", "of", "variables", "are", "4", "then", "the", "list", "will", "be", "[", "var_0", "var...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/UAI.py#L98-L119
[ "def", "get_variables", "(", "self", ")", ":", "variables", "=", "[", "]", "for", "var", "in", "range", "(", "0", ",", "self", ".", "no_variables", ")", ":", "var_name", "=", "\"var_\"", "+", "str", "(", "var", ")", "variables", ".", "append", "(", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
UAIReader.get_domain
Returns the dictionary of variables with keys as variable name and values as domain of the variables. Returns ------- dict: dictionary containing variables and their domains Example ------- >>> reader = UAIReader('TestUAI.uai') >>> reader.get_domain() ...
pgmpy/readwrite/UAI.py
def get_domain(self): """ Returns the dictionary of variables with keys as variable name and values as domain of the variables. Returns ------- dict: dictionary containing variables and their domains Example ------- >>> reader = UAIReader('TestUA...
def get_domain(self): """ Returns the dictionary of variables with keys as variable name and values as domain of the variables. Returns ------- dict: dictionary containing variables and their domains Example ------- >>> reader = UAIReader('TestUA...
[ "Returns", "the", "dictionary", "of", "variables", "with", "keys", "as", "variable", "name", "and", "values", "as", "domain", "of", "the", "variables", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/UAI.py#L121-L140
[ "def", "get_domain", "(", "self", ")", ":", "domain", "=", "{", "}", "var_domain", "=", "self", ".", "grammar", ".", "parseString", "(", "self", ".", "network", ")", "[", "'domain_variables'", "]", "for", "var", "in", "range", "(", "0", ",", "len", "...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
UAIReader.get_edges
Returns the edges of the network. Returns ------- set: set containing the edges of the network Example ------- >>> reader = UAIReader('TestUAI.uai') >>> reader.get_edges() {('var_0', 'var_1'), ('var_0', 'var_2'), ('var_1', 'var_2')}
pgmpy/readwrite/UAI.py
def get_edges(self): """ Returns the edges of the network. Returns ------- set: set containing the edges of the network Example ------- >>> reader = UAIReader('TestUAI.uai') >>> reader.get_edges() {('var_0', 'var_1'), ('var_0', 'var_2'), ...
def get_edges(self): """ Returns the edges of the network. Returns ------- set: set containing the edges of the network Example ------- >>> reader = UAIReader('TestUAI.uai') >>> reader.get_edges() {('var_0', 'var_1'), ('var_0', 'var_2'), ...
[ "Returns", "the", "edges", "of", "the", "network", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/UAI.py#L142-L169
[ "def", "get_edges", "(", "self", ")", ":", "edges", "=", "[", "]", "for", "function", "in", "range", "(", "0", ",", "self", ".", "no_functions", ")", ":", "function_variables", "=", "self", ".", "grammar", ".", "parseString", "(", "self", ".", "network...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
UAIReader.get_tables
Returns list of tuple of child variable and CPD in case of Bayesian and list of tuple of scope of variables and values in case of Markov. Returns ------- list : list of tuples of child variable and values in Bayesian list of tuples of scope of variables and values in case of...
pgmpy/readwrite/UAI.py
def get_tables(self): """ Returns list of tuple of child variable and CPD in case of Bayesian and list of tuple of scope of variables and values in case of Markov. Returns ------- list : list of tuples of child variable and values in Bayesian list of tuples o...
def get_tables(self): """ Returns list of tuple of child variable and CPD in case of Bayesian and list of tuple of scope of variables and values in case of Markov. Returns ------- list : list of tuples of child variable and values in Bayesian list of tuples o...
[ "Returns", "list", "of", "tuple", "of", "child", "variable", "and", "CPD", "in", "case", "of", "Bayesian", "and", "list", "of", "tuple", "of", "scope", "of", "variables", "and", "values", "in", "case", "of", "Markov", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/UAI.py#L171-L203
[ "def", "get_tables", "(", "self", ")", ":", "tables", "=", "[", "]", "for", "function", "in", "range", "(", "0", ",", "self", ".", "no_functions", ")", ":", "function_variables", "=", "self", ".", "grammar", ".", "parseString", "(", "self", ".", "netwo...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
UAIReader.get_model
Returns an instance of Bayesian Model or Markov Model. Varibles are in the pattern var_0, var_1, var_2 where var_0 is 0th index variable, var_1 is 1st index variable. Return ------ model: an instance of Bayesian or Markov Model. Examples -------- >>> rea...
pgmpy/readwrite/UAI.py
def get_model(self): """ Returns an instance of Bayesian Model or Markov Model. Varibles are in the pattern var_0, var_1, var_2 where var_0 is 0th index variable, var_1 is 1st index variable. Return ------ model: an instance of Bayesian or Markov Model. ...
def get_model(self): """ Returns an instance of Bayesian Model or Markov Model. Varibles are in the pattern var_0, var_1, var_2 where var_0 is 0th index variable, var_1 is 1st index variable. Return ------ model: an instance of Bayesian or Markov Model. ...
[ "Returns", "an", "instance", "of", "Bayesian", "Model", "or", "Markov", "Model", ".", "Varibles", "are", "in", "the", "pattern", "var_0", "var_1", "var_2", "where", "var_0", "is", "0th", "index", "variable", "var_1", "is", "1st", "index", "variable", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/UAI.py#L205-L249
[ "def", "get_model", "(", "self", ")", ":", "if", "self", ".", "network_type", "==", "'BAYES'", ":", "model", "=", "BayesianModel", "(", ")", "model", ".", "add_nodes_from", "(", "self", ".", "variables", ")", "model", ".", "add_edges_from", "(", "self", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
UAIWriter.get_domain
Adds domain of each variable to the network. Example ------- >>> writer = UAIWriter(model) >>> writer.get_domain()
pgmpy/readwrite/UAI.py
def get_domain(self): """ Adds domain of each variable to the network. Example ------- >>> writer = UAIWriter(model) >>> writer.get_domain() """ if isinstance(self.model, BayesianModel): cpds = self.model.get_cpds() cpds.sort(key=l...
def get_domain(self): """ Adds domain of each variable to the network. Example ------- >>> writer = UAIWriter(model) >>> writer.get_domain() """ if isinstance(self.model, BayesianModel): cpds = self.model.get_cpds() cpds.sort(key=l...
[ "Adds", "domain", "of", "each", "variable", "to", "the", "network", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/UAI.py#L307-L333
[ "def", "get_domain", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "model", ",", "BayesianModel", ")", ":", "cpds", "=", "self", ".", "model", ".", "get_cpds", "(", ")", "cpds", ".", "sort", "(", "key", "=", "lambda", "x", ":", "x", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
UAIWriter.get_functions
Adds functions to the network. Example ------- >>> writer = UAIWriter(model) >>> writer.get_functions()
pgmpy/readwrite/UAI.py
def get_functions(self): """ Adds functions to the network. Example ------- >>> writer = UAIWriter(model) >>> writer.get_functions() """ if isinstance(self.model, BayesianModel): cpds = self.model.get_cpds() cpds.sort(key=lambda x:...
def get_functions(self): """ Adds functions to the network. Example ------- >>> writer = UAIWriter(model) >>> writer.get_functions() """ if isinstance(self.model, BayesianModel): cpds = self.model.get_cpds() cpds.sort(key=lambda x:...
[ "Adds", "functions", "to", "the", "network", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/UAI.py#L335-L366
[ "def", "get_functions", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "model", ",", "BayesianModel", ")", ":", "cpds", "=", "self", ".", "model", ".", "get_cpds", "(", ")", "cpds", ".", "sort", "(", "key", "=", "lambda", "x", ":", "x...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
UAIWriter.get_tables
Adds tables to the network. Example ------- >>> writer = UAIWriter(model) >>> writer.get_tables()
pgmpy/readwrite/UAI.py
def get_tables(self): """ Adds tables to the network. Example ------- >>> writer = UAIWriter(model) >>> writer.get_tables() """ if isinstance(self.model, BayesianModel): cpds = self.model.get_cpds() cpds.sort(key=lambda x: x.variab...
def get_tables(self): """ Adds tables to the network. Example ------- >>> writer = UAIWriter(model) >>> writer.get_tables() """ if isinstance(self.model, BayesianModel): cpds = self.model.get_cpds() cpds.sort(key=lambda x: x.variab...
[ "Adds", "tables", "to", "the", "network", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/UAI.py#L368-L393
[ "def", "get_tables", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "model", ",", "BayesianModel", ")", ":", "cpds", "=", "self", ".", "model", ".", "get_cpds", "(", ")", "cpds", ".", "sort", "(", "key", "=", "lambda", "x", ":", "x", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
UAIWriter.write_uai
Write the xml data into the file. Parameters ---------- filename: Name of the file. Examples ------- >>> writer = UAIWriter(model) >>> writer.write_xmlbif(test_file)
pgmpy/readwrite/UAI.py
def write_uai(self, filename): """ Write the xml data into the file. Parameters ---------- filename: Name of the file. Examples ------- >>> writer = UAIWriter(model) >>> writer.write_xmlbif(test_file) """ writer = self.__str__() ...
def write_uai(self, filename): """ Write the xml data into the file. Parameters ---------- filename: Name of the file. Examples ------- >>> writer = UAIWriter(model) >>> writer.write_xmlbif(test_file) """ writer = self.__str__() ...
[ "Write", "the", "xml", "data", "into", "the", "file", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/readwrite/UAI.py#L395-L410
[ "def", "write_uai", "(", "self", ",", "filename", ")", ":", "writer", "=", "self", ".", "__str__", "(", ")", "with", "open", "(", "filename", ",", "'w'", ")", "as", "fout", ":", "fout", ".", "write", "(", "writer", ")" ]
9381a66aba3c3871d3ccd00672b148d17d63239e
train
K2Score.local_score
Computes a score that measures how much a \ given variable is \"influenced\" by a given list of potential parents.
pgmpy/estimators/K2Score.py
def local_score(self, variable, parents): "Computes a score that measures how much a \ given variable is \"influenced\" by a given list of potential parents." var_states = self.state_names[variable] var_cardinality = len(var_states) state_counts = self.state_counts(variable, par...
def local_score(self, variable, parents): "Computes a score that measures how much a \ given variable is \"influenced\" by a given list of potential parents." var_states = self.state_names[variable] var_cardinality = len(var_states) state_counts = self.state_counts(variable, par...
[ "Computes", "a", "score", "that", "measures", "how", "much", "a", "\\", "given", "variable", "is", "\\", "influenced", "\\", "by", "a", "given", "list", "of", "potential", "parents", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/K2Score.py#L41-L58
[ "def", "local_score", "(", "self", ",", "variable", ",", "parents", ")", ":", "var_states", "=", "self", ".", "state_names", "[", "variable", "]", "var_cardinality", "=", "len", "(", "var_states", ")", "state_counts", "=", "self", ".", "state_counts", "(", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
_clean_check
Run the command to download target. If the command fails, clean up before re-raising the error.
ez_setup.py
def _clean_check(cmd, target): """ Run the command to download target. If the command fails, clean up before re-raising the error. """ try: subprocess.check_call(cmd) except subprocess.CalledProcessError: if os.access(target, os.F_OK): os.unlink(target) raise
def _clean_check(cmd, target): """ Run the command to download target. If the command fails, clean up before re-raising the error. """ try: subprocess.check_call(cmd) except subprocess.CalledProcessError: if os.access(target, os.F_OK): os.unlink(target) raise
[ "Run", "the", "command", "to", "download", "target", ".", "If", "the", "command", "fails", "clean", "up", "before", "re", "-", "raising", "the", "error", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/ez_setup.py#L149-L159
[ "def", "_clean_check", "(", "cmd", ",", "target", ")", ":", "try", ":", "subprocess", ".", "check_call", "(", "cmd", ")", "except", "subprocess", ".", "CalledProcessError", ":", "if", "os", ".", "access", "(", "target", ",", "os", ".", "F_OK", ")", ":"...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
download_file_powershell
Download the file at url to target using Powershell (which will validate trust). Raise an exception if the command cannot complete.
ez_setup.py
def download_file_powershell(url, target): """ Download the file at url to target using Powershell (which will validate trust). Raise an exception if the command cannot complete. """ target = os.path.abspath(target) cmd = [ 'powershell', '-Command', "(new-object System.Ne...
def download_file_powershell(url, target): """ Download the file at url to target using Powershell (which will validate trust). Raise an exception if the command cannot complete. """ target = os.path.abspath(target) cmd = [ 'powershell', '-Command', "(new-object System.Ne...
[ "Download", "the", "file", "at", "url", "to", "target", "using", "Powershell", "(", "which", "will", "validate", "trust", ")", ".", "Raise", "an", "exception", "if", "the", "command", "cannot", "complete", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/ez_setup.py#L161-L172
[ "def", "download_file_powershell", "(", "url", ",", "target", ")", ":", "target", "=", "os", ".", "path", ".", "abspath", "(", "target", ")", "cmd", "=", "[", "'powershell'", ",", "'-Command'", ",", "\"(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
download_setuptools
Download setuptools from a specified location and return its filename `version` should be a valid setuptools version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded. `delay` is the nu...
ez_setup.py
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15, downloader_factory=get_best_downloader): """Download setuptools from a specified location and return its filename `version` should be a valid setuptools versio...
def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15, downloader_factory=get_best_downloader): """Download setuptools from a specified location and return its filename `version` should be a valid setuptools versio...
[ "Download", "setuptools", "from", "a", "specified", "location", "and", "return", "its", "filename" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/ez_setup.py#L263-L286
[ "def", "download_setuptools", "(", "version", "=", "DEFAULT_VERSION", ",", "download_base", "=", "DEFAULT_URL", ",", "to_dir", "=", "os", ".", "curdir", ",", "delay", "=", "15", ",", "downloader_factory", "=", "get_best_downloader", ")", ":", "# making sure we use...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
_parse_args
Parse the command line for options
ez_setup.py
def _parse_args(): """ Parse the command line for options """ parser = optparse.OptionParser() parser.add_option( '--user', dest='user_install', action='store_true', default=False, help='install in user site package (requires Python 2.6 or later)') parser.add_option( '--d...
def _parse_args(): """ Parse the command line for options """ parser = optparse.OptionParser() parser.add_option( '--user', dest='user_install', action='store_true', default=False, help='install in user site package (requires Python 2.6 or later)') parser.add_option( '--d...
[ "Parse", "the", "command", "line", "for", "options" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/ez_setup.py#L335-L354
[ "def", "_parse_args", "(", ")", ":", "parser", "=", "optparse", ".", "OptionParser", "(", ")", "parser", ".", "add_option", "(", "'--user'", ",", "dest", "=", "'user_install'", ",", "action", "=", "'store_true'", ",", "default", "=", "False", ",", "help", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModel.add_edge
Add an edge between u and v. The nodes u and v will be automatically added if they are not already in the graph Parameters ---------- u,v : nodes Nodes can be any hashable python object. Examples -------- >>> from pgmpy.models import Bayes...
pgmpy/models/BayesianModel.py
def add_edge(self, u, v, **kwargs): """ Add an edge between u and v. The nodes u and v will be automatically added if they are not already in the graph Parameters ---------- u,v : nodes Nodes can be any hashable python object. Examples ...
def add_edge(self, u, v, **kwargs): """ Add an edge between u and v. The nodes u and v will be automatically added if they are not already in the graph Parameters ---------- u,v : nodes Nodes can be any hashable python object. Examples ...
[ "Add", "an", "edge", "between", "u", "and", "v", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/BayesianModel.py#L95-L120
[ "def", "add_edge", "(", "self", ",", "u", ",", "v", ",", "*", "*", "kwargs", ")", ":", "if", "u", "==", "v", ":", "raise", "ValueError", "(", "'Self loops are not allowed.'", ")", "if", "u", "in", "self", ".", "nodes", "(", ")", "and", "v", "in", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModel.remove_node
Remove node from the model. Removing a node also removes all the associated edges, removes the CPD of the node and marginalizes the CPDs of it's children. Parameters ---------- node : node Node which is to be removed from the model. Returns ------- ...
pgmpy/models/BayesianModel.py
def remove_node(self, node): """ Remove node from the model. Removing a node also removes all the associated edges, removes the CPD of the node and marginalizes the CPDs of it's children. Parameters ---------- node : node Node which is to be removed ...
def remove_node(self, node): """ Remove node from the model. Removing a node also removes all the associated edges, removes the CPD of the node and marginalizes the CPDs of it's children. Parameters ---------- node : node Node which is to be removed ...
[ "Remove", "node", "from", "the", "model", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/BayesianModel.py#L122-L168
[ "def", "remove_node", "(", "self", ",", "node", ")", ":", "affected_nodes", "=", "[", "v", "for", "u", ",", "v", "in", "self", ".", "edges", "(", ")", "if", "u", "==", "node", "]", "for", "affected_node", "in", "affected_nodes", ":", "node_cpd", "=",...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModel.add_cpds
Add CPD (Conditional Probability Distribution) to the Bayesian Model. Parameters ---------- cpds : list, set, tuple (array-like) List of CPDs which will be associated with the model EXAMPLE ------- >>> from pgmpy.models import BayesianModel >>> fro...
pgmpy/models/BayesianModel.py
def add_cpds(self, *cpds): """ Add CPD (Conditional Probability Distribution) to the Bayesian Model. Parameters ---------- cpds : list, set, tuple (array-like) List of CPDs which will be associated with the model EXAMPLE ------- >>> from pg...
def add_cpds(self, *cpds): """ Add CPD (Conditional Probability Distribution) to the Bayesian Model. Parameters ---------- cpds : list, set, tuple (array-like) List of CPDs which will be associated with the model EXAMPLE ------- >>> from pg...
[ "Add", "CPD", "(", "Conditional", "Probability", "Distribution", ")", "to", "the", "Bayesian", "Model", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/BayesianModel.py#L209-L255
[ "def", "add_cpds", "(", "self", ",", "*", "cpds", ")", ":", "for", "cpd", "in", "cpds", ":", "if", "not", "isinstance", "(", "cpd", ",", "(", "TabularCPD", ",", "ContinuousFactor", ")", ")", ":", "raise", "ValueError", "(", "'Only TabularCPD or ContinuousF...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModel.get_cpds
Returns the cpd of the node. If node is not specified returns all the CPDs that have been added till now to the graph Parameter --------- node: any hashable python object (optional) The node whose CPD we want. If node not specified returns all the CPDs added to t...
pgmpy/models/BayesianModel.py
def get_cpds(self, node=None): """ Returns the cpd of the node. If node is not specified returns all the CPDs that have been added till now to the graph Parameter --------- node: any hashable python object (optional) The node whose CPD we want. If node not sp...
def get_cpds(self, node=None): """ Returns the cpd of the node. If node is not specified returns all the CPDs that have been added till now to the graph Parameter --------- node: any hashable python object (optional) The node whose CPD we want. If node not sp...
[ "Returns", "the", "cpd", "of", "the", "node", ".", "If", "node", "is", "not", "specified", "returns", "all", "the", "CPDs", "that", "have", "been", "added", "till", "now", "to", "the", "graph" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/BayesianModel.py#L257-L292
[ "def", "get_cpds", "(", "self", ",", "node", "=", "None", ")", ":", "if", "node", "is", "not", "None", ":", "if", "node", "not", "in", "self", ".", "nodes", "(", ")", ":", "raise", "ValueError", "(", "'Node not present in the Directed Graph'", ")", "for"...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModel.remove_cpds
Removes the cpds that are provided in the argument. Parameters ---------- *cpds: TabularCPD object A CPD object on any subset of the variables of the model which is to be associated with the model. Examples -------- >>> from pgmpy.models import B...
pgmpy/models/BayesianModel.py
def remove_cpds(self, *cpds): """ Removes the cpds that are provided in the argument. Parameters ---------- *cpds: TabularCPD object A CPD object on any subset of the variables of the model which is to be associated with the model. Examples ...
def remove_cpds(self, *cpds): """ Removes the cpds that are provided in the argument. Parameters ---------- *cpds: TabularCPD object A CPD object on any subset of the variables of the model which is to be associated with the model. Examples ...
[ "Removes", "the", "cpds", "that", "are", "provided", "in", "the", "argument", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/BayesianModel.py#L294-L318
[ "def", "remove_cpds", "(", "self", ",", "*", "cpds", ")", ":", "for", "cpd", "in", "cpds", ":", "if", "isinstance", "(", "cpd", ",", "six", ".", "string_types", ")", ":", "cpd", "=", "self", ".", "get_cpds", "(", "cpd", ")", "self", ".", "cpds", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModel.get_cardinality
Returns the cardinality of the node. Throws an error if the CPD for the queried node hasn't been added to the network. Parameters ---------- node: Any hashable python object(optional). The node whose cardinality we want. If node is not specified returns a dic...
pgmpy/models/BayesianModel.py
def get_cardinality(self, node=None): """ Returns the cardinality of the node. Throws an error if the CPD for the queried node hasn't been added to the network. Parameters ---------- node: Any hashable python object(optional). The node whose cardinality we ...
def get_cardinality(self, node=None): """ Returns the cardinality of the node. Throws an error if the CPD for the queried node hasn't been added to the network. Parameters ---------- node: Any hashable python object(optional). The node whose cardinality we ...
[ "Returns", "the", "cardinality", "of", "the", "node", ".", "Throws", "an", "error", "if", "the", "CPD", "for", "the", "queried", "node", "hasn", "t", "been", "added", "to", "the", "network", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/BayesianModel.py#L320-L362
[ "def", "get_cardinality", "(", "self", ",", "node", "=", "None", ")", ":", "if", "node", ":", "return", "self", ".", "get_cpds", "(", "node", ")", ".", "cardinality", "[", "0", "]", "else", ":", "cardinalities", "=", "defaultdict", "(", "int", ")", "...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModel.check_model
Check the model for various errors. This method checks for the following errors. * Checks if the sum of the probabilities for each state is equal to 1 (tol=0.01). * Checks if the CPDs associated with nodes are consistent with their parents. Returns ------- check: boolea...
pgmpy/models/BayesianModel.py
def check_model(self): """ Check the model for various errors. This method checks for the following errors. * Checks if the sum of the probabilities for each state is equal to 1 (tol=0.01). * Checks if the CPDs associated with nodes are consistent with their parents. Re...
def check_model(self): """ Check the model for various errors. This method checks for the following errors. * Checks if the sum of the probabilities for each state is equal to 1 (tol=0.01). * Checks if the CPDs associated with nodes are consistent with their parents. Re...
[ "Check", "the", "model", "for", "various", "errors", ".", "This", "method", "checks", "for", "the", "following", "errors", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/BayesianModel.py#L364-L391
[ "def", "check_model", "(", "self", ")", ":", "for", "node", "in", "self", ".", "nodes", "(", ")", ":", "cpd", "=", "self", ".", "get_cpds", "(", "node", "=", "node", ")", "if", "cpd", "is", "None", ":", "raise", "ValueError", "(", "'No CPD associated...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModel.to_markov_model
Converts bayesian model to markov model. The markov model created would be the moral graph of the bayesian model. Examples -------- >>> from pgmpy.models import BayesianModel >>> G = BayesianModel([('diff', 'grade'), ('intel', 'grade'), ... ('intel', '...
pgmpy/models/BayesianModel.py
def to_markov_model(self): """ Converts bayesian model to markov model. The markov model created would be the moral graph of the bayesian model. Examples -------- >>> from pgmpy.models import BayesianModel >>> G = BayesianModel([('diff', 'grade'), ('intel', 'grad...
def to_markov_model(self): """ Converts bayesian model to markov model. The markov model created would be the moral graph of the bayesian model. Examples -------- >>> from pgmpy.models import BayesianModel >>> G = BayesianModel([('diff', 'grade'), ('intel', 'grad...
[ "Converts", "bayesian", "model", "to", "markov", "model", ".", "The", "markov", "model", "created", "would", "be", "the", "moral", "graph", "of", "the", "bayesian", "model", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/BayesianModel.py#L393-L414
[ "def", "to_markov_model", "(", "self", ")", ":", "moral_graph", "=", "self", ".", "moralize", "(", ")", "mm", "=", "MarkovModel", "(", "moral_graph", ".", "edges", "(", ")", ")", "mm", ".", "add_factors", "(", "*", "[", "cpd", ".", "to_factor", "(", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModel.fit
Estimates the CPD for each variable based on a given data set. Parameters ---------- data: pandas DataFrame object DataFrame object with column names identical to the variable names of the network. (If some values in the data are missing the data cells should be set to `...
pgmpy/models/BayesianModel.py
def fit(self, data, estimator=None, state_names=[], complete_samples_only=True, **kwargs): """ Estimates the CPD for each variable based on a given data set. Parameters ---------- data: pandas DataFrame object DataFrame object with column names identical to the varia...
def fit(self, data, estimator=None, state_names=[], complete_samples_only=True, **kwargs): """ Estimates the CPD for each variable based on a given data set. Parameters ---------- data: pandas DataFrame object DataFrame object with column names identical to the varia...
[ "Estimates", "the", "CPD", "for", "each", "variable", "based", "on", "a", "given", "data", "set", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/BayesianModel.py#L456-L509
[ "def", "fit", "(", "self", ",", "data", ",", "estimator", "=", "None", ",", "state_names", "=", "[", "]", ",", "complete_samples_only", "=", "True", ",", "*", "*", "kwargs", ")", ":", "from", "pgmpy", ".", "estimators", "import", "MaximumLikelihoodEstimato...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModel.predict
Predicts states of all the missing variables. Parameters ---------- data : pandas DataFrame object A DataFrame object with column names same as the variables in the model. Examples -------- >>> import numpy as np >>> import pandas as pd >>> f...
pgmpy/models/BayesianModel.py
def predict(self, data): """ Predicts states of all the missing variables. Parameters ---------- data : pandas DataFrame object A DataFrame object with column names same as the variables in the model. Examples -------- >>> import numpy as np ...
def predict(self, data): """ Predicts states of all the missing variables. Parameters ---------- data : pandas DataFrame object A DataFrame object with column names same as the variables in the model. Examples -------- >>> import numpy as np ...
[ "Predicts", "states", "of", "all", "the", "missing", "variables", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/BayesianModel.py#L511-L567
[ "def", "predict", "(", "self", ",", "data", ")", ":", "from", "pgmpy", ".", "inference", "import", "VariableElimination", "if", "set", "(", "data", ".", "columns", ")", "==", "set", "(", "self", ".", "nodes", "(", ")", ")", ":", "raise", "ValueError", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModel.predict_probability
Predicts probabilities of all states of the missing variables. Parameters ---------- data : pandas DataFrame object A DataFrame object with column names same as the variables in the model. Examples -------- >>> import numpy as np >>> import pandas as...
pgmpy/models/BayesianModel.py
def predict_probability(self, data): """ Predicts probabilities of all states of the missing variables. Parameters ---------- data : pandas DataFrame object A DataFrame object with column names same as the variables in the model. Examples -------- ...
def predict_probability(self, data): """ Predicts probabilities of all states of the missing variables. Parameters ---------- data : pandas DataFrame object A DataFrame object with column names same as the variables in the model. Examples -------- ...
[ "Predicts", "probabilities", "of", "all", "states", "of", "the", "missing", "variables", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/BayesianModel.py#L569-L636
[ "def", "predict_probability", "(", "self", ",", "data", ")", ":", "from", "pgmpy", ".", "inference", "import", "VariableElimination", "if", "set", "(", "data", ".", "columns", ")", "==", "set", "(", "self", ".", "nodes", "(", ")", ")", ":", "raise", "V...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModel.is_imap
Checks whether the bayesian model is Imap of given JointProbabilityDistribution Parameters ----------- JPD : An instance of JointProbabilityDistribution Class, for which you want to check the Imap Returns -------- boolean : True if bayesian model is Imap for...
pgmpy/models/BayesianModel.py
def is_imap(self, JPD): """ Checks whether the bayesian model is Imap of given JointProbabilityDistribution Parameters ----------- JPD : An instance of JointProbabilityDistribution Class, for which you want to check the Imap Returns -------- ...
def is_imap(self, JPD): """ Checks whether the bayesian model is Imap of given JointProbabilityDistribution Parameters ----------- JPD : An instance of JointProbabilityDistribution Class, for which you want to check the Imap Returns -------- ...
[ "Checks", "whether", "the", "bayesian", "model", "is", "Imap", "of", "given", "JointProbabilityDistribution" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/BayesianModel.py#L642-L684
[ "def", "is_imap", "(", "self", ",", "JPD", ")", ":", "if", "not", "isinstance", "(", "JPD", ",", "JointProbabilityDistribution", ")", ":", "raise", "TypeError", "(", "\"JPD must be an instance of JointProbabilityDistribution\"", ")", "factors", "=", "[", "cpd", "....
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BayesianModel.copy
Returns a copy of the model. Returns ------- BayesianModel: Copy of the model on which the method was called. Examples -------- >>> from pgmpy.models import BayesianModel >>> from pgmpy.factors.discrete import TabularCPD >>> model = BayesianModel([('A', ...
pgmpy/models/BayesianModel.py
def copy(self): """ Returns a copy of the model. Returns ------- BayesianModel: Copy of the model on which the method was called. Examples -------- >>> from pgmpy.models import BayesianModel >>> from pgmpy.factors.discrete import TabularCPD ...
def copy(self): """ Returns a copy of the model. Returns ------- BayesianModel: Copy of the model on which the method was called. Examples -------- >>> from pgmpy.models import BayesianModel >>> from pgmpy.factors.discrete import TabularCPD ...
[ "Returns", "a", "copy", "of", "the", "model", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/BayesianModel.py#L686-L722
[ "def", "copy", "(", "self", ")", ":", "model_copy", "=", "BayesianModel", "(", ")", "model_copy", ".", "add_nodes_from", "(", "self", ".", "nodes", "(", ")", ")", "model_copy", ".", "add_edges_from", "(", "self", ".", "edges", "(", ")", ")", "if", "sel...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
TabularCPD.get_values
Returns the cpd Examples -------- >>> from pgmpy.factors.discrete import TabularCPD >>> cpd = TabularCPD('grade', 3, [[0.1, 0.1], ... [0.1, 0.1], ... [0.8, 0.8]], ... evidence='evi1', ev...
pgmpy/factors/discrete/CPD.py
def get_values(self): """ Returns the cpd Examples -------- >>> from pgmpy.factors.discrete import TabularCPD >>> cpd = TabularCPD('grade', 3, [[0.1, 0.1], ... [0.1, 0.1], ... [0.8, 0.8]], ...
def get_values(self): """ Returns the cpd Examples -------- >>> from pgmpy.factors.discrete import TabularCPD >>> cpd = TabularCPD('grade', 3, [[0.1, 0.1], ... [0.1, 0.1], ... [0.8, 0.8]], ...
[ "Returns", "the", "cpd" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/discrete/CPD.py#L149-L168
[ "def", "get_values", "(", "self", ")", ":", "if", "self", ".", "variable", "in", "self", ".", "variables", ":", "return", "self", ".", "values", ".", "reshape", "(", "self", ".", "cardinality", "[", "0", "]", ",", "np", ".", "prod", "(", "self", "....
9381a66aba3c3871d3ccd00672b148d17d63239e
train
TabularCPD.copy
Returns a copy of the TabularCPD object. Examples -------- >>> from pgmpy.factors.discrete import TabularCPD >>> cpd = TabularCPD('grade', 2, ... [[0.7, 0.6, 0.6, 0.2],[0.3, 0.4, 0.4, 0.8]], ... ['intel', 'diff'], [2, 2]) >>> cop...
pgmpy/factors/discrete/CPD.py
def copy(self): """ Returns a copy of the TabularCPD object. Examples -------- >>> from pgmpy.factors.discrete import TabularCPD >>> cpd = TabularCPD('grade', 2, ... [[0.7, 0.6, 0.6, 0.2],[0.3, 0.4, 0.4, 0.8]], ... ['inte...
def copy(self): """ Returns a copy of the TabularCPD object. Examples -------- >>> from pgmpy.factors.discrete import TabularCPD >>> cpd = TabularCPD('grade', 2, ... [[0.7, 0.6, 0.6, 0.2],[0.3, 0.4, 0.4, 0.8]], ... ['inte...
[ "Returns", "a", "copy", "of", "the", "TabularCPD", "object", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/discrete/CPD.py#L210-L237
[ "def", "copy", "(", "self", ")", ":", "evidence", "=", "self", ".", "variables", "[", "1", ":", "]", "if", "len", "(", "self", ".", "variables", ")", ">", "1", "else", "None", "evidence_card", "=", "self", ".", "cardinality", "[", "1", ":", "]", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
TabularCPD.normalize
Normalizes the cpd table. Parameters ---------- inplace: boolean If inplace=True it will modify the CPD itself, else would return a new CPD Examples -------- >>> from pgmpy.factors.discrete import TabularCPD >>> cpd_table = TabularCPD('gr...
pgmpy/factors/discrete/CPD.py
def normalize(self, inplace=True): """ Normalizes the cpd table. Parameters ---------- inplace: boolean If inplace=True it will modify the CPD itself, else would return a new CPD Examples -------- >>> from pgmpy.factors.discrete i...
def normalize(self, inplace=True): """ Normalizes the cpd table. Parameters ---------- inplace: boolean If inplace=True it will modify the CPD itself, else would return a new CPD Examples -------- >>> from pgmpy.factors.discrete i...
[ "Normalizes", "the", "cpd", "table", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/discrete/CPD.py#L239-L264
[ "def", "normalize", "(", "self", ",", "inplace", "=", "True", ")", ":", "tabular_cpd", "=", "self", "if", "inplace", "else", "self", ".", "copy", "(", ")", "cpd", "=", "tabular_cpd", ".", "get_values", "(", ")", "tabular_cpd", ".", "values", "=", "(", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
TabularCPD.marginalize
Modifies the cpd table with marginalized values. Parameters ---------- variables: list, array-like list of variable to be marginalized inplace: boolean If inplace=True it will modify the CPD itself, else would return a new CPD Examples ...
pgmpy/factors/discrete/CPD.py
def marginalize(self, variables, inplace=True): """ Modifies the cpd table with marginalized values. Parameters ---------- variables: list, array-like list of variable to be marginalized inplace: boolean If inplace=True it will modify the CPD its...
def marginalize(self, variables, inplace=True): """ Modifies the cpd table with marginalized values. Parameters ---------- variables: list, array-like list of variable to be marginalized inplace: boolean If inplace=True it will modify the CPD its...
[ "Modifies", "the", "cpd", "table", "with", "marginalized", "values", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/discrete/CPD.py#L266-L299
[ "def", "marginalize", "(", "self", ",", "variables", ",", "inplace", "=", "True", ")", ":", "if", "self", ".", "variable", "in", "variables", ":", "raise", "ValueError", "(", "\"Marginalization not allowed on the variable on which CPD is defined\"", ")", "tabular_cpd"...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
TabularCPD.reduce
Reduces the cpd table to the context of given variable values. Parameters ---------- values: list, array-like A list of tuples of the form (variable_name, variable_state). inplace: boolean If inplace=True it will modify the factor itself, else would return ...
pgmpy/factors/discrete/CPD.py
def reduce(self, values, inplace=True): """ Reduces the cpd table to the context of given variable values. Parameters ---------- values: list, array-like A list of tuples of the form (variable_name, variable_state). inplace: boolean If inplace=Tr...
def reduce(self, values, inplace=True): """ Reduces the cpd table to the context of given variable values. Parameters ---------- values: list, array-like A list of tuples of the form (variable_name, variable_state). inplace: boolean If inplace=Tr...
[ "Reduces", "the", "cpd", "table", "to", "the", "context", "of", "given", "variable", "values", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/discrete/CPD.py#L302-L335
[ "def", "reduce", "(", "self", ",", "values", ",", "inplace", "=", "True", ")", ":", "if", "self", ".", "variable", "in", "(", "value", "[", "0", "]", "for", "value", "in", "values", ")", ":", "raise", "ValueError", "(", "\"Reduce not allowed on the varia...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
TabularCPD.reorder_parents
Returns a new cpd table according to provided order. Parameters ---------- new_order: list list of new ordering of variables inplace: boolean If inplace == True it will modify the CPD itself otherwise new value will be returned without affecting old ...
pgmpy/factors/discrete/CPD.py
def reorder_parents(self, new_order, inplace=True): """ Returns a new cpd table according to provided order. Parameters ---------- new_order: list list of new ordering of variables inplace: boolean If inplace == True it will modify the CPD itself...
def reorder_parents(self, new_order, inplace=True): """ Returns a new cpd table according to provided order. Parameters ---------- new_order: list list of new ordering of variables inplace: boolean If inplace == True it will modify the CPD itself...
[ "Returns", "a", "new", "cpd", "table", "according", "to", "provided", "order", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/discrete/CPD.py#L354-L464
[ "def", "reorder_parents", "(", "self", ",", "new_order", ",", "inplace", "=", "True", ")", ":", "if", "(", "len", "(", "self", ".", "variables", ")", "<=", "1", "or", "(", "set", "(", "new_order", ")", "-", "set", "(", "self", ".", "variables", ")"...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
LinearGaussianBayesianNetwork.add_cpds
Add linear Gaussian CPD (Conditional Probability Distribution) to the Bayesian Model. Parameters ---------- cpds : instances of LinearGaussianCPD List of LinearGaussianCPDs which will be associated with the model Examples -------- >>> from pgmpy.mo...
pgmpy/models/LinearGaussianBayesianNetwork.py
def add_cpds(self, *cpds): """ Add linear Gaussian CPD (Conditional Probability Distribution) to the Bayesian Model. Parameters ---------- cpds : instances of LinearGaussianCPD List of LinearGaussianCPDs which will be associated with the model Exam...
def add_cpds(self, *cpds): """ Add linear Gaussian CPD (Conditional Probability Distribution) to the Bayesian Model. Parameters ---------- cpds : instances of LinearGaussianCPD List of LinearGaussianCPDs which will be associated with the model Exam...
[ "Add", "linear", "Gaussian", "CPD", "(", "Conditional", "Probability", "Distribution", ")", "to", "the", "Bayesian", "Model", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/LinearGaussianBayesianNetwork.py#L23-L64
[ "def", "add_cpds", "(", "self", ",", "*", "cpds", ")", ":", "for", "cpd", "in", "cpds", ":", "if", "not", "isinstance", "(", "cpd", ",", "LinearGaussianCPD", ")", ":", "raise", "ValueError", "(", "'Only LinearGaussianCPD can be added.'", ")", "if", "set", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
LinearGaussianBayesianNetwork.to_joint_gaussian
The linear Gaussian Bayesian Networks are an alternative representation for the class of multivariate Gaussian distributions. This method returns an equivalent joint Gaussian distribution. Returns ------- GaussianDistribution: An equivalent joint Gaussian ...
pgmpy/models/LinearGaussianBayesianNetwork.py
def to_joint_gaussian(self): """ The linear Gaussian Bayesian Networks are an alternative representation for the class of multivariate Gaussian distributions. This method returns an equivalent joint Gaussian distribution. Returns ------- GaussianDistribution: An ...
def to_joint_gaussian(self): """ The linear Gaussian Bayesian Networks are an alternative representation for the class of multivariate Gaussian distributions. This method returns an equivalent joint Gaussian distribution. Returns ------- GaussianDistribution: An ...
[ "The", "linear", "Gaussian", "Bayesian", "Networks", "are", "an", "alternative", "representation", "for", "the", "class", "of", "multivariate", "Gaussian", "distributions", ".", "This", "method", "returns", "an", "equivalent", "joint", "Gaussian", "distribution", "....
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/LinearGaussianBayesianNetwork.py#L129-L189
[ "def", "to_joint_gaussian", "(", "self", ")", ":", "variables", "=", "nx", ".", "topological_sort", "(", "self", ")", "mean", "=", "np", ".", "zeros", "(", "len", "(", "variables", ")", ")", "covariance", "=", "np", ".", "zeros", "(", "(", "len", "("...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
LinearGaussianBayesianNetwork.check_model
Checks the model for various errors. This method checks for the following error - * Checks if the CPDs associated with nodes are consistent with their parents. Returns ------- check: boolean True if all the checks pass.
pgmpy/models/LinearGaussianBayesianNetwork.py
def check_model(self): """ Checks the model for various errors. This method checks for the following error - * Checks if the CPDs associated with nodes are consistent with their parents. Returns ------- check: boolean True if all the checks pass. ...
def check_model(self): """ Checks the model for various errors. This method checks for the following error - * Checks if the CPDs associated with nodes are consistent with their parents. Returns ------- check: boolean True if all the checks pass. ...
[ "Checks", "the", "model", "for", "various", "errors", ".", "This", "method", "checks", "for", "the", "following", "error", "-" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/LinearGaussianBayesianNetwork.py#L191-L211
[ "def", "check_model", "(", "self", ")", ":", "for", "node", "in", "self", ".", "nodes", "(", ")", ":", "cpd", "=", "self", ".", "get_cpds", "(", "node", "=", "node", ")", "if", "isinstance", "(", "cpd", ",", "LinearGaussianCPD", ")", ":", "if", "se...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
factorset_product
r""" Base method used for product of factor sets. Suppose :math:`\vec\phi_1` and :math:`\vec\phi_2` are two factor sets then their product is a another factors set :math:`\vec\phi_3 = \vec\phi_1 \cup \vec\phi_2`. Parameters ---------- factorsets_list: FactorSet1, FactorSet2, ..., FactorSetn ...
pgmpy/factors/FactorSet.py
def factorset_product(*factorsets_list): r""" Base method used for product of factor sets. Suppose :math:`\vec\phi_1` and :math:`\vec\phi_2` are two factor sets then their product is a another factors set :math:`\vec\phi_3 = \vec\phi_1 \cup \vec\phi_2`. Parameters ---------- factorsets_lis...
def factorset_product(*factorsets_list): r""" Base method used for product of factor sets. Suppose :math:`\vec\phi_1` and :math:`\vec\phi_2` are two factor sets then their product is a another factors set :math:`\vec\phi_3 = \vec\phi_1 \cup \vec\phi_2`. Parameters ---------- factorsets_lis...
[ "r", "Base", "method", "used", "for", "product", "of", "factor", "sets", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/FactorSet.py#L297-L334
[ "def", "factorset_product", "(", "*", "factorsets_list", ")", ":", "if", "not", "all", "(", "isinstance", "(", "factorset", ",", "FactorSet", ")", "for", "factorset", "in", "factorsets_list", ")", ":", "raise", "TypeError", "(", "\"Input parameters must be FactorS...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
factorset_divide
r""" Base method for dividing two factor sets. Division of two factor sets :math:`\frac{\vec\phi_1}{\vec\phi_2}` basically translates to union of all the factors present in :math:`\vec\phi_2` and :math:`\frac{1}{\phi_i}` of all the factors present in :math:`\vec\phi_2`. Parameters ---------- f...
pgmpy/factors/FactorSet.py
def factorset_divide(factorset1, factorset2): r""" Base method for dividing two factor sets. Division of two factor sets :math:`\frac{\vec\phi_1}{\vec\phi_2}` basically translates to union of all the factors present in :math:`\vec\phi_2` and :math:`\frac{1}{\phi_i}` of all the factors present in :math:...
def factorset_divide(factorset1, factorset2): r""" Base method for dividing two factor sets. Division of two factor sets :math:`\frac{\vec\phi_1}{\vec\phi_2}` basically translates to union of all the factors present in :math:`\vec\phi_2` and :math:`\frac{1}{\phi_i}` of all the factors present in :math:...
[ "r", "Base", "method", "for", "dividing", "two", "factor", "sets", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/FactorSet.py#L337-L377
[ "def", "factorset_divide", "(", "factorset1", ",", "factorset2", ")", ":", "if", "not", "isinstance", "(", "factorset1", ",", "FactorSet", ")", "or", "not", "isinstance", "(", "factorset2", ",", "FactorSet", ")", ":", "raise", "TypeError", "(", "\"factorset1 a...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
FactorSet.product
r""" Return the factor sets product with the given factor sets Suppose :math:`\vec\phi_1` and :math:`\vec\phi_2` are two factor sets then their product is a another factors set :math:`\vec\phi_3 = \vec\phi_1 \cup \vec\phi_2`. Parameters ---------- factorsets: FactorSet1...
pgmpy/factors/FactorSet.py
def product(self, factorset, inplace=True): r""" Return the factor sets product with the given factor sets Suppose :math:`\vec\phi_1` and :math:`\vec\phi_2` are two factor sets then their product is a another factors set :math:`\vec\phi_3 = \vec\phi_1 \cup \vec\phi_2`. Paramete...
def product(self, factorset, inplace=True): r""" Return the factor sets product with the given factor sets Suppose :math:`\vec\phi_1` and :math:`\vec\phi_2` are two factor sets then their product is a another factors set :math:`\vec\phi_3 = \vec\phi_1 \cup \vec\phi_2`. Paramete...
[ "r", "Return", "the", "factor", "sets", "product", "with", "the", "given", "factor", "sets" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/FactorSet.py#L120-L171
[ "def", "product", "(", "self", ",", "factorset", ",", "inplace", "=", "True", ")", ":", "factor_set", "=", "self", "if", "inplace", "else", "self", ".", "copy", "(", ")", "factor_set1", "=", "factorset", ".", "copy", "(", ")", "factor_set", ".", "add_f...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
FactorSet.divide
r""" Returns a new factor set instance after division by the factor set Division of two factor sets :math:`\frac{\vec\phi_1}{\vec\phi_2}` basically translates to union of all the factors present in :math:`\vec\phi_2` and :math:`\frac{1}{\phi_i}` of all the factors present in :math:`\vec...
pgmpy/factors/FactorSet.py
def divide(self, factorset, inplace=True): r""" Returns a new factor set instance after division by the factor set Division of two factor sets :math:`\frac{\vec\phi_1}{\vec\phi_2}` basically translates to union of all the factors present in :math:`\vec\phi_2` and :math:`\frac{1}{\phi_i}...
def divide(self, factorset, inplace=True): r""" Returns a new factor set instance after division by the factor set Division of two factor sets :math:`\frac{\vec\phi_1}{\vec\phi_2}` basically translates to union of all the factors present in :math:`\vec\phi_2` and :math:`\frac{1}{\phi_i}...
[ "r", "Returns", "a", "new", "factor", "set", "instance", "after", "division", "by", "the", "factor", "set" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/FactorSet.py#L173-L218
[ "def", "divide", "(", "self", ",", "factorset", ",", "inplace", "=", "True", ")", ":", "factor_set", "=", "self", "if", "inplace", "else", "self", ".", "copy", "(", ")", "factor_set1", "=", "factorset", ".", "copy", "(", ")", "factor_set", ".", "add_fa...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
FactorSet.marginalize
Marginalizes the factors present in the factor sets with respect to the given variables. Parameters ---------- variables: list, array-like List of the variables to be marginalized. inplace: boolean (Default value True) If inplace=True it will modify the factor s...
pgmpy/factors/FactorSet.py
def marginalize(self, variables, inplace=True): """ Marginalizes the factors present in the factor sets with respect to the given variables. Parameters ---------- variables: list, array-like List of the variables to be marginalized. inplace: boolean (Default...
def marginalize(self, variables, inplace=True): """ Marginalizes the factors present in the factor sets with respect to the given variables. Parameters ---------- variables: list, array-like List of the variables to be marginalized. inplace: boolean (Default...
[ "Marginalizes", "the", "factors", "present", "in", "the", "factor", "sets", "with", "respect", "to", "the", "given", "variables", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/factors/FactorSet.py#L220-L265
[ "def", "marginalize", "(", "self", ",", "variables", ",", "inplace", "=", "True", ")", ":", "if", "isinstance", "(", "variables", ",", "six", ".", "string_types", ")", ":", "raise", "TypeError", "(", "'Expected list or array-like type got type str'", ")", "facto...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
DynamicBayesianNetwork.add_node
Adds a single node to the Network Parameters ---------- node: node A node can be any hashable Python object. Examples -------- >>> from pgmpy.models import DynamicBayesianNetwork as DBN >>> dbn = DBN() >>> dbn.add_node('A') ['A']
pgmpy/models/DynamicBayesianNetwork.py
def add_node(self, node, **attr): """ Adds a single node to the Network Parameters ---------- node: node A node can be any hashable Python object. Examples -------- >>> from pgmpy.models import DynamicBayesianNetwork as DBN >>> dbn = ...
def add_node(self, node, **attr): """ Adds a single node to the Network Parameters ---------- node: node A node can be any hashable Python object. Examples -------- >>> from pgmpy.models import DynamicBayesianNetwork as DBN >>> dbn = ...
[ "Adds", "a", "single", "node", "to", "the", "Network" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/DynamicBayesianNetwork.py#L84-L100
[ "def", "add_node", "(", "self", ",", "node", ",", "*", "*", "attr", ")", ":", "super", "(", "DynamicBayesianNetwork", ",", "self", ")", ".", "add_node", "(", "(", "node", ",", "0", ")", ",", "*", "*", "attr", ")" ]
9381a66aba3c3871d3ccd00672b148d17d63239e
train
DynamicBayesianNetwork._nodes
Returns the list of nodes present in the network Examples -------- >>> from pgmpy.models import DynamicBayesianNetwork as DBN >>> dbn = DBN() >>> dbn.add_nodes_from(['A', 'B', 'C']) >>> sorted(dbn._nodes()) ['B', 'A', 'C']
pgmpy/models/DynamicBayesianNetwork.py
def _nodes(self): """ Returns the list of nodes present in the network Examples -------- >>> from pgmpy.models import DynamicBayesianNetwork as DBN >>> dbn = DBN() >>> dbn.add_nodes_from(['A', 'B', 'C']) >>> sorted(dbn._nodes()) ['B', 'A', 'C'] ...
def _nodes(self): """ Returns the list of nodes present in the network Examples -------- >>> from pgmpy.models import DynamicBayesianNetwork as DBN >>> dbn = DBN() >>> dbn.add_nodes_from(['A', 'B', 'C']) >>> sorted(dbn._nodes()) ['B', 'A', 'C'] ...
[ "Returns", "the", "list", "of", "nodes", "present", "in", "the", "network" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/DynamicBayesianNetwork.py#L120-L133
[ "def", "_nodes", "(", "self", ")", ":", "return", "list", "(", "set", "(", "[", "node", "for", "node", ",", "timeslice", "in", "super", "(", "DynamicBayesianNetwork", ",", "self", ")", ".", "nodes", "(", ")", "]", ")", ")" ]
9381a66aba3c3871d3ccd00672b148d17d63239e
train
DynamicBayesianNetwork.add_edge
Add an edge between two nodes. The nodes will be automatically added if they are not present in the network. Parameters ---------- start: tuple Both the start and end nodes should specify the time slice as (node_name, time_slice). Here, node_name can be an...
pgmpy/models/DynamicBayesianNetwork.py
def add_edge(self, start, end, **kwargs): """ Add an edge between two nodes. The nodes will be automatically added if they are not present in the network. Parameters ---------- start: tuple Both the start and end nodes should specify the time slice as ...
def add_edge(self, start, end, **kwargs): """ Add an edge between two nodes. The nodes will be automatically added if they are not present in the network. Parameters ---------- start: tuple Both the start and end nodes should specify the time slice as ...
[ "Add", "an", "edge", "between", "two", "nodes", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/DynamicBayesianNetwork.py#L135-L195
[ "def", "add_edge", "(", "self", ",", "start", ",", "end", ",", "*", "*", "kwargs", ")", ":", "try", ":", "if", "len", "(", "start", ")", "!=", "2", "or", "len", "(", "end", ")", "!=", "2", ":", "raise", "ValueError", "(", "'Nodes must be of type (n...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
DynamicBayesianNetwork.add_edges_from
Add all the edges in ebunch. If nodes referred in the ebunch are not already present, they will be automatically added. Node names can be any hashable python object. Parameters ---------- ebunch : list, array-like List of edges to add. Each edge must be of the f...
pgmpy/models/DynamicBayesianNetwork.py
def add_edges_from(self, ebunch, **kwargs): """ Add all the edges in ebunch. If nodes referred in the ebunch are not already present, they will be automatically added. Node names can be any hashable python object. Parameters ---------- ebunch : list, array-like ...
def add_edges_from(self, ebunch, **kwargs): """ Add all the edges in ebunch. If nodes referred in the ebunch are not already present, they will be automatically added. Node names can be any hashable python object. Parameters ---------- ebunch : list, array-like ...
[ "Add", "all", "the", "edges", "in", "ebunch", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/DynamicBayesianNetwork.py#L197-L224
[ "def", "add_edges_from", "(", "self", ",", "ebunch", ",", "*", "*", "kwargs", ")", ":", "for", "edge", "in", "ebunch", ":", "self", ".", "add_edge", "(", "edge", "[", "0", "]", ",", "edge", "[", "1", "]", ")" ]
9381a66aba3c3871d3ccd00672b148d17d63239e
train
DynamicBayesianNetwork.get_intra_edges
Returns the intra slice edges present in the 2-TBN. Parameter --------- time_slice: int (whole number) The time slice for which to get intra edges. The timeslice should be a positive value or zero. Examples -------- >>> from pgmpy.models ...
pgmpy/models/DynamicBayesianNetwork.py
def get_intra_edges(self, time_slice=0): """ Returns the intra slice edges present in the 2-TBN. Parameter --------- time_slice: int (whole number) The time slice for which to get intra edges. The timeslice should be a positive value or zero. ...
def get_intra_edges(self, time_slice=0): """ Returns the intra slice edges present in the 2-TBN. Parameter --------- time_slice: int (whole number) The time slice for which to get intra edges. The timeslice should be a positive value or zero. ...
[ "Returns", "the", "intra", "slice", "edges", "present", "in", "the", "2", "-", "TBN", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/DynamicBayesianNetwork.py#L226-L251
[ "def", "get_intra_edges", "(", "self", ",", "time_slice", "=", "0", ")", ":", "if", "not", "isinstance", "(", "time_slice", ",", "int", ")", "or", "time_slice", "<", "0", ":", "raise", "ValueError", "(", "\"The timeslice should be a positive value greater than or ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
DynamicBayesianNetwork.get_interface_nodes
Returns the nodes in the first timeslice whose children are present in the first timeslice. Parameters ---------- time_slice:int The timeslice should be a positive value greater than or equal to zero Examples -------- >>> from pgmpy.models import Dynamic...
pgmpy/models/DynamicBayesianNetwork.py
def get_interface_nodes(self, time_slice=0): """ Returns the nodes in the first timeslice whose children are present in the first timeslice. Parameters ---------- time_slice:int The timeslice should be a positive value greater than or equal to zero Examp...
def get_interface_nodes(self, time_slice=0): """ Returns the nodes in the first timeslice whose children are present in the first timeslice. Parameters ---------- time_slice:int The timeslice should be a positive value greater than or equal to zero Examp...
[ "Returns", "the", "nodes", "in", "the", "first", "timeslice", "whose", "children", "are", "present", "in", "the", "first", "timeslice", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/DynamicBayesianNetwork.py#L274-L295
[ "def", "get_interface_nodes", "(", "self", ",", "time_slice", "=", "0", ")", ":", "if", "not", "isinstance", "(", "time_slice", ",", "int", ")", "or", "time_slice", "<", "0", ":", "raise", "ValueError", "(", "\"The timeslice should be a positive value greater than...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
DynamicBayesianNetwork.get_slice_nodes
Returns the nodes present in a particular timeslice Parameters ---------- time_slice:int The timeslice should be a positive value greater than or equal to zero Examples -------- >>> from pgmpy.models import DynamicBayesianNetwork as DBN >>> dbn =...
pgmpy/models/DynamicBayesianNetwork.py
def get_slice_nodes(self, time_slice=0): """ Returns the nodes present in a particular timeslice Parameters ---------- time_slice:int The timeslice should be a positive value greater than or equal to zero Examples -------- >>> from pgmpy....
def get_slice_nodes(self, time_slice=0): """ Returns the nodes present in a particular timeslice Parameters ---------- time_slice:int The timeslice should be a positive value greater than or equal to zero Examples -------- >>> from pgmpy....
[ "Returns", "the", "nodes", "present", "in", "a", "particular", "timeslice" ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/DynamicBayesianNetwork.py#L297-L317
[ "def", "get_slice_nodes", "(", "self", ",", "time_slice", "=", "0", ")", ":", "if", "not", "isinstance", "(", "time_slice", ",", "int", ")", "or", "time_slice", "<", "0", ":", "raise", "ValueError", "(", "\"The timeslice should be a positive value greater than or ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
DynamicBayesianNetwork.add_cpds
This method adds the cpds to the dynamic bayesian network. Note that while adding variables and the evidence in cpd, they have to be of the following form (node_name, time_slice) Here, node_name is the node that is inserted while the time_slice is an integer value, which denotes ...
pgmpy/models/DynamicBayesianNetwork.py
def add_cpds(self, *cpds): """ This method adds the cpds to the dynamic bayesian network. Note that while adding variables and the evidence in cpd, they have to be of the following form (node_name, time_slice) Here, node_name is the node that is inserted while the...
def add_cpds(self, *cpds): """ This method adds the cpds to the dynamic bayesian network. Note that while adding variables and the evidence in cpd, they have to be of the following form (node_name, time_slice) Here, node_name is the node that is inserted while the...
[ "This", "method", "adds", "the", "cpds", "to", "the", "dynamic", "bayesian", "network", ".", "Note", "that", "while", "adding", "variables", "and", "the", "evidence", "in", "cpd", "they", "have", "to", "be", "of", "the", "following", "form", "(", "node_nam...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/DynamicBayesianNetwork.py#L319-L372
[ "def", "add_cpds", "(", "self", ",", "*", "cpds", ")", ":", "for", "cpd", "in", "cpds", ":", "if", "not", "isinstance", "(", "cpd", ",", "TabularCPD", ")", ":", "raise", "ValueError", "(", "'cpd should be an instance of TabularCPD'", ")", "if", "set", "(",...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
DynamicBayesianNetwork.get_cpds
Returns the CPDs that have been associated with the network. Parameters ---------- node: tuple (node_name, time_slice) The node should be in the following form (node_name, time_slice). Here, node_name is the node that is inserted while the time_slice is an in...
pgmpy/models/DynamicBayesianNetwork.py
def get_cpds(self, node=None, time_slice=0): """ Returns the CPDs that have been associated with the network. Parameters ---------- node: tuple (node_name, time_slice) The node should be in the following form (node_name, time_slice). Here, node_name is th...
def get_cpds(self, node=None, time_slice=0): """ Returns the CPDs that have been associated with the network. Parameters ---------- node: tuple (node_name, time_slice) The node should be in the following form (node_name, time_slice). Here, node_name is th...
[ "Returns", "the", "CPDs", "that", "have", "been", "associated", "with", "the", "network", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/DynamicBayesianNetwork.py#L374-L410
[ "def", "get_cpds", "(", "self", ",", "node", "=", "None", ",", "time_slice", "=", "0", ")", ":", "# TODO: fix bugs in this", "if", "node", ":", "if", "node", "not", "in", "super", "(", "DynamicBayesianNetwork", ",", "self", ")", ".", "nodes", "(", ")", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
DynamicBayesianNetwork.remove_cpds
Removes the cpds that are provided in the argument. Parameters ---------- *cpds : list, set, tuple (array-like) List of CPDs which are to be associated with the model. Each CPD should be an instance of `TabularCPD`. Examples -------- >>> from pgm...
pgmpy/models/DynamicBayesianNetwork.py
def remove_cpds(self, *cpds): """ Removes the cpds that are provided in the argument. Parameters ---------- *cpds : list, set, tuple (array-like) List of CPDs which are to be associated with the model. Each CPD should be an instance of `TabularCPD`. ...
def remove_cpds(self, *cpds): """ Removes the cpds that are provided in the argument. Parameters ---------- *cpds : list, set, tuple (array-like) List of CPDs which are to be associated with the model. Each CPD should be an instance of `TabularCPD`. ...
[ "Removes", "the", "cpds", "that", "are", "provided", "in", "the", "argument", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/DynamicBayesianNetwork.py#L412-L441
[ "def", "remove_cpds", "(", "self", ",", "*", "cpds", ")", ":", "for", "cpd", "in", "cpds", ":", "if", "isinstance", "(", "cpd", ",", "(", "tuple", ",", "list", ")", ")", ":", "cpd", "=", "self", ".", "get_cpds", "(", "cpd", ")", "self", ".", "c...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
DynamicBayesianNetwork.check_model
Check the model for various errors. This method checks for the following errors. * Checks if the sum of the probabilities in each associated CPD for each state is equal to 1 (tol=0.01). * Checks if the CPDs associated with nodes are consistent with their parents. Returns ...
pgmpy/models/DynamicBayesianNetwork.py
def check_model(self): """ Check the model for various errors. This method checks for the following errors. * Checks if the sum of the probabilities in each associated CPD for each state is equal to 1 (tol=0.01). * Checks if the CPDs associated with nodes are consist...
def check_model(self): """ Check the model for various errors. This method checks for the following errors. * Checks if the sum of the probabilities in each associated CPD for each state is equal to 1 (tol=0.01). * Checks if the CPDs associated with nodes are consist...
[ "Check", "the", "model", "for", "various", "errors", ".", "This", "method", "checks", "for", "the", "following", "errors", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/DynamicBayesianNetwork.py#L443-L471
[ "def", "check_model", "(", "self", ")", ":", "for", "node", "in", "super", "(", "DynamicBayesianNetwork", ",", "self", ")", ".", "nodes", "(", ")", ":", "cpd", "=", "self", ".", "get_cpds", "(", "node", "=", "node", ")", "if", "isinstance", "(", "cpd...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
DynamicBayesianNetwork.initialize_initial_state
This method will automatically re-adjust the cpds and the edges added to the bayesian network. If an edge that is added as an intra time slice edge in the 0th timeslice, this method will automatically add it in the 1st timeslice. It will also add the cpds. However, to call this method, one needs...
pgmpy/models/DynamicBayesianNetwork.py
def initialize_initial_state(self): """ This method will automatically re-adjust the cpds and the edges added to the bayesian network. If an edge that is added as an intra time slice edge in the 0th timeslice, this method will automatically add it in the 1st timeslice. It will also add t...
def initialize_initial_state(self): """ This method will automatically re-adjust the cpds and the edges added to the bayesian network. If an edge that is added as an intra time slice edge in the 0th timeslice, this method will automatically add it in the 1st timeslice. It will also add t...
[ "This", "method", "will", "automatically", "re", "-", "adjust", "the", "cpds", "and", "the", "edges", "added", "to", "the", "bayesian", "network", ".", "If", "an", "edge", "that", "is", "added", "as", "an", "intra", "time", "slice", "edge", "in", "the", ...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/DynamicBayesianNetwork.py#L473-L523
[ "def", "initialize_initial_state", "(", "self", ")", ":", "for", "cpd", "in", "self", ".", "cpds", ":", "temp_var", "=", "(", "cpd", ".", "variable", "[", "0", "]", ",", "1", "-", "cpd", ".", "variable", "[", "1", "]", ")", "parents", "=", "self", ...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
DynamicBayesianNetwork.moralize
Removes all the immoralities in the Network and creates a moral graph (UndirectedGraph). A v-structure X->Z<-Y is an immorality if there is no directed edge between X and Y. Examples -------- >>> from pgmpy.models import DynamicBayesianNetwork as DBN >>> dbn = D...
pgmpy/models/DynamicBayesianNetwork.py
def moralize(self): """ Removes all the immoralities in the Network and creates a moral graph (UndirectedGraph). A v-structure X->Z<-Y is an immorality if there is no directed edge between X and Y. Examples -------- >>> from pgmpy.models import DynamicBa...
def moralize(self): """ Removes all the immoralities in the Network and creates a moral graph (UndirectedGraph). A v-structure X->Z<-Y is an immorality if there is no directed edge between X and Y. Examples -------- >>> from pgmpy.models import DynamicBa...
[ "Removes", "all", "the", "immoralities", "in", "the", "Network", "and", "creates", "a", "moral", "graph", "(", "UndirectedGraph", ")", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/DynamicBayesianNetwork.py#L525-L552
[ "def", "moralize", "(", "self", ")", ":", "moral_graph", "=", "self", ".", "to_undirected", "(", ")", "for", "node", "in", "super", "(", "DynamicBayesianNetwork", ",", "self", ")", ".", "nodes", "(", ")", ":", "moral_graph", ".", "add_edges_from", "(", "...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
DynamicBayesianNetwork.copy
Returns a copy of the dynamic bayesian network. Returns ------- DynamicBayesianNetwork: copy of the dynamic bayesian network Examples -------- >>> from pgmpy.models import DynamicBayesianNetwork as DBN >>> from pgmpy.factors.discrete import TabularCPD >>...
pgmpy/models/DynamicBayesianNetwork.py
def copy(self): """ Returns a copy of the dynamic bayesian network. Returns ------- DynamicBayesianNetwork: copy of the dynamic bayesian network Examples -------- >>> from pgmpy.models import DynamicBayesianNetwork as DBN >>> from pgmpy.factors.d...
def copy(self): """ Returns a copy of the dynamic bayesian network. Returns ------- DynamicBayesianNetwork: copy of the dynamic bayesian network Examples -------- >>> from pgmpy.models import DynamicBayesianNetwork as DBN >>> from pgmpy.factors.d...
[ "Returns", "a", "copy", "of", "the", "dynamic", "bayesian", "network", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/models/DynamicBayesianNetwork.py#L554-L590
[ "def", "copy", "(", "self", ")", ":", "dbn", "=", "DynamicBayesianNetwork", "(", ")", "dbn", ".", "add_nodes_from", "(", "self", ".", "_nodes", "(", ")", ")", "dbn", ".", "add_edges_from", "(", "self", ".", "edges", "(", ")", ")", "cpd_copy", "=", "[...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
HillClimbSearch._legal_operations
Generates a list of legal (= not in tabu_list) graph modifications for a given model, together with their score changes. Possible graph modifications: (1) add, (2) remove, or (3) flip a single edge. For details on scoring see Koller & Fridman, Probabilistic Graphical Models, Section 18.4.3.3 (pa...
pgmpy/estimators/HillClimbSearch.py
def _legal_operations(self, model, tabu_list=[], max_indegree=None): """Generates a list of legal (= not in tabu_list) graph modifications for a given model, together with their score changes. Possible graph modifications: (1) add, (2) remove, or (3) flip a single edge. For details on scoring ...
def _legal_operations(self, model, tabu_list=[], max_indegree=None): """Generates a list of legal (= not in tabu_list) graph modifications for a given model, together with their score changes. Possible graph modifications: (1) add, (2) remove, or (3) flip a single edge. For details on scoring ...
[ "Generates", "a", "list", "of", "legal", "(", "=", "not", "in", "tabu_list", ")", "graph", "modifications", "for", "a", "given", "model", "together", "with", "their", "score", "changes", ".", "Possible", "graph", "modifications", ":", "(", "1", ")", "add",...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/HillClimbSearch.py#L45-L94
[ "def", "_legal_operations", "(", "self", ",", "model", ",", "tabu_list", "=", "[", "]", ",", "max_indegree", "=", "None", ")", ":", "local_score", "=", "self", ".", "scoring_method", ".", "local_score", "nodes", "=", "self", ".", "state_names", ".", "keys"...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
HillClimbSearch.estimate
Performs local hill climb search to estimates the `DAG` structure that has optimal score, according to the scoring method supplied in the constructor. Starts at model `start` and proceeds by step-by-step network modifications until a local maximum is reached. Only estimates network structure, no...
pgmpy/estimators/HillClimbSearch.py
def estimate(self, start=None, tabu_length=0, max_indegree=None): """ Performs local hill climb search to estimates the `DAG` structure that has optimal score, according to the scoring method supplied in the constructor. Starts at model `start` and proceeds by step-by-step network modifi...
def estimate(self, start=None, tabu_length=0, max_indegree=None): """ Performs local hill climb search to estimates the `DAG` structure that has optimal score, according to the scoring method supplied in the constructor. Starts at model `start` and proceeds by step-by-step network modifi...
[ "Performs", "local", "hill", "climb", "search", "to", "estimates", "the", "DAG", "structure", "that", "has", "optimal", "score", "according", "to", "the", "scoring", "method", "supplied", "in", "the", "constructor", ".", "Starts", "at", "model", "start", "and"...
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/estimators/HillClimbSearch.py#L96-L173
[ "def", "estimate", "(", "self", ",", "start", "=", "None", ",", "tabu_length", "=", "0", ",", "max_indegree", "=", "None", ")", ":", "epsilon", "=", "1e-8", "nodes", "=", "self", ".", "state_names", ".", "keys", "(", ")", "if", "start", "is", "None",...
9381a66aba3c3871d3ccd00672b148d17d63239e
train
BaseEliminationOrder.get_elimination_order
Returns the optimal elimination order based on the cost function. The node having the least cost is removed first. Parameters ---------- nodes: list, tuple, set (array-like) The variables which are to be eliminated. Examples -------- >>> import numpy...
pgmpy/inference/EliminationOrder.py
def get_elimination_order(self, nodes=None): """ Returns the optimal elimination order based on the cost function. The node having the least cost is removed first. Parameters ---------- nodes: list, tuple, set (array-like) The variables which are to be elimin...
def get_elimination_order(self, nodes=None): """ Returns the optimal elimination order based on the cost function. The node having the least cost is removed first. Parameters ---------- nodes: list, tuple, set (array-like) The variables which are to be elimin...
[ "Returns", "the", "optimal", "elimination", "order", "based", "on", "the", "cost", "function", ".", "The", "node", "having", "the", "least", "cost", "is", "removed", "first", "." ]
pgmpy/pgmpy
python
https://github.com/pgmpy/pgmpy/blob/9381a66aba3c3871d3ccd00672b148d17d63239e/pgmpy/inference/EliminationOrder.py#L41-L93
[ "def", "get_elimination_order", "(", "self", ",", "nodes", "=", "None", ")", ":", "if", "not", "nodes", ":", "nodes", "=", "self", ".", "bayesian_model", ".", "nodes", "(", ")", "nodes", "=", "set", "(", "nodes", ")", "ordering", "=", "[", "]", "whil...
9381a66aba3c3871d3ccd00672b148d17d63239e