[pyAgrum] minimal doc for pyagrum.BayesNetFragment

parent 27b5e649
......@@ -22,7 +22,7 @@ variable : pyAgrum.DiscreteVariable
name : str
the variable name
nbrmod : int
the numbre of modalities for the new variable
the number of modalities for the new variable
id : int
the variable forced id in the pyAgrum.BayesNet
......@@ -36,7 +36,7 @@ Raises
gum.DuplicateLabel
If variable.name() is already used in this pyAgrum.BayesNet.
gum.NotAllowed
If nbrmod<2
If nbrmod is less than 2
gum.DuplicateElement
If id is already used.
"
......
......@@ -15,11 +15,11 @@
%include "doc_Instantiation.i"
%include "doc_Potential.i"
%include "doc_BayesNet.i"
%include "doc_DAGmodel.i"
%include "doc_IBayesNet.i"
%include "doc_DAGmodel.i"
%include "doc_BayesNet.i"
%include "doc_BayesNetFragment.i"
%include "doc_EssentialGraph.i"
%include "doc_MarkovBlanket.i"
%include "doc_BNdistance.i"
......
......@@ -9506,7 +9506,7 @@ class BayesNet(IBayesNet):
name : str
the variable name
nbrmod : int
the numbre of modalities for the new variable
the number of modalities for the new variable
id : int
the variable forced id in the pyAgrum.BayesNet
......@@ -9520,7 +9520,7 @@ class BayesNet(IBayesNet):
gum.DuplicateLabel
If variable.name() is already used in this pyAgrum.BayesNet.
gum.NotAllowed
If nbrmod<2
If nbrmod is less than 2
gum.DuplicateElement
If id is already used.
......@@ -10672,8 +10672,15 @@ def BayesNet_fastPrototype(dotlike, domainSize=2):
class BayesNetFragment(IBayesNet, ):
r"""
Proxy of C++ gum::BayesNetFragment< double > class.
Proxy of C++ gum::BayesNetFragment< double > class.
BayesNetFragment represents a part of a Bayesian Network (subset of nodes). By default, the arcs and the CPTs are the same as the BN but local CPTs can be build to express different local dependencies. All the non local CPTs are not copied. Therefore a BayesNetFragment is a light object.
BayesNetFragment(BayesNet bn) -> BayesNetFragment
Parameters:
* **bn** (*pyAgrum.BayesNet*) -- the bn refered by the fragment
"""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
......@@ -10848,6 +10855,14 @@ class BayesNetFragment(IBayesNet, ):
r"""
isInstalledNode(BayesNetFragment self, gum::NodeId id) -> bool
isInstalledNode(BayesNetFragment self, std::string const & name) -> bool
Check if a node is in the fragment
Parameters
----------
n : int, str
the id or the name of the variable.
"""
return _pyAgrum.BayesNetFragment_isInstalledNode(self, *args)
......@@ -10855,6 +10870,21 @@ class BayesNetFragment(IBayesNet, ):
r"""
installNode(BayesNetFragment self, gum::NodeId id)
installNode(BayesNetFragment self, std::string const & name)
Add a node to the fragment. The arcs that can be added between installed nodes are created.
No specific CPT are created. Then either the parents of the node are already in the fragment
and the node is consistant, or the parents are not in the fragment and the node is not consistant.
Parameters
----------
n : int, str
the id or the name of the variable.
Raises
------
gum.NotFound
if the node is not found.
"""
return _pyAgrum.BayesNetFragment_installNode(self, *args)
......@@ -10862,6 +10892,19 @@ class BayesNetFragment(IBayesNet, ):
r"""
installAscendants(BayesNetFragment self, gum::NodeId id)
installAscendants(BayesNetFragment self, std::string const & name)
Add the variable and all its ascendants in the fragment. No inconsistant node are created.
Parameters
----------
n : int, str
the id or the name of the variable.
Raises
------
gum.NotFound
if the node is not found.
"""
return _pyAgrum.BayesNetFragment_installAscendants(self, *args)
......@@ -10869,6 +10912,19 @@ class BayesNetFragment(IBayesNet, ):
r"""
uninstallNode(BayesNetFragment self, gum::NodeId id)
uninstallNode(BayesNetFragment self, std::string const & name)
Remove a node from the fragment. The fragment can become inconsistant.
Parameters
----------
n : int, str
the id or the name of the variable.
Raises
------
gum.NotFound
if the node is not found.
"""
return _pyAgrum.BayesNetFragment_uninstallNode(self, *args)
......@@ -10876,6 +10932,21 @@ class BayesNetFragment(IBayesNet, ):
r"""
installMarginal(BayesNetFragment self, gum::NodeId id, Potential pot)
installMarginal(BayesNetFragment self, std::string const & name, Potential pot)
Install a local marginal for a node. Doing so, it removes the parents of the node in the fragment.
Parameters
----------
n : int, str
the id or the name of the variable.
pot : Potential
the Potential (marginal) to install
Raises
------
gum.NotFound
if the node is not found.
"""
return _pyAgrum.BayesNetFragment_installMarginal(self, *args)
......@@ -10883,6 +10954,21 @@ class BayesNetFragment(IBayesNet, ):
r"""
installCPT(BayesNetFragment self, gum::NodeId id, Potential pot)
installCPT(BayesNetFragment self, std::string const & name, Potential pot)
Install a local CPT for a node. Doing so, it changes the parents of the node in the fragment.
Parameters
----------
n : int, str
the id or the name of the variable.
pot : Potential
the Potential to install
Raises
------
gum.NotFound
if the node is not found.
"""
return _pyAgrum.BayesNetFragment_installCPT(self, *args)
......@@ -10890,6 +10976,19 @@ class BayesNetFragment(IBayesNet, ):
r"""
uninstallCPT(BayesNetFragment self, gum::NodeId id)
uninstallCPT(BayesNetFragment self, std::string const & name)
Remove a local CPT. The fragment can become inconsistant.
Parameters
----------
n : int, str
the id or the name of the variable.
Raises
------
gum.NotFound
if the node is not found.
"""
return _pyAgrum.BayesNetFragment_uninstallCPT(self, *args)
......@@ -10898,6 +10997,25 @@ class BayesNetFragment(IBayesNet, ):
checkConsistency(BayesNetFragment self, gum::NodeId id) -> bool
checkConsistency(BayesNetFragment self, std::string const & name) -> bool
checkConsistency(BayesNetFragment self) -> bool
If a variable is added to the fragment but not its parents, there is no CPT consistant for this variable. This function checks the consistency for a variable of for all.
Parameters
----------
n : int, str (optional)
the id or the name of the variable. If no argument, the function checks all the variables.
Returns
-------
boolean
True if the variable(s) is consistant.
Raises
------
gum.NotFound
if the node is not found.
"""
return _pyAgrum.BayesNetFragment_checkConsistency(self, *args)
......
......@@ -123438,7 +123438,7 @@ static PyMethodDef SwigMethods[] = {
"name : str \n"
" the variable name\n"
"nbrmod : int\n"
" the numbre of modalities for the new variable\n"
" the number of modalities for the new variable\n"
"id : int\n"
" the variable forced id in the pyAgrum.BayesNet\n"
"\n"
......@@ -123452,7 +123452,7 @@ static PyMethodDef SwigMethods[] = {
"gum.DuplicateLabel\n"
" If variable.name() is already used in this pyAgrum.BayesNet.\n"
"gum.NotAllowed\n"
" If nbrmod<2\n"
" If nbrmod is less than 2\n"
"gum.DuplicateElement\n"
" If id is already used.\n"
"\n"
......@@ -124507,35 +124507,146 @@ static PyMethodDef SwigMethods[] = {
{ "BayesNetFragment_isInstalledNode", _wrap_BayesNetFragment_isInstalledNode, METH_VARARGS, "\n"
"BayesNetFragment_isInstalledNode(BayesNetFragment self, gum::NodeId id) -> bool\n"
"BayesNetFragment_isInstalledNode(BayesNetFragment self, std::string const & name) -> bool\n"
"\n"
"Check if a node is in the fragment\n"
"\n"
"Parameters\n"
"----------\n"
"n : int, str\n"
" the id or the name of the variable.\n"
"\n"
""},
{ "BayesNetFragment_installNode", _wrap_BayesNetFragment_installNode, METH_VARARGS, "\n"
"BayesNetFragment_installNode(BayesNetFragment self, gum::NodeId id)\n"
"BayesNetFragment_installNode(BayesNetFragment self, std::string const & name)\n"
"\n"
"Add a node to the fragment. The arcs that can be added between installed nodes are created.\n"
"No specific CPT are created. Then either the parents of the node are already in the fragment \n"
"and the node is consistant, or the parents are not in the fragment and the node is not consistant.\n"
"\n"
"Parameters\n"
"----------\n"
"n : int, str\n"
" the id or the name of the variable.\n"
"\n"
"Raises\n"
"------\n"
"gum.NotFound\n"
" if the node is not found.\n"
"\n"
""},
{ "BayesNetFragment_installAscendants", _wrap_BayesNetFragment_installAscendants, METH_VARARGS, "\n"
"BayesNetFragment_installAscendants(BayesNetFragment self, gum::NodeId id)\n"
"BayesNetFragment_installAscendants(BayesNetFragment self, std::string const & name)\n"
"\n"
"Add the variable and all its ascendants in the fragment. No inconsistant node are created.\n"
"\n"
"Parameters\n"
"----------\n"
"n : int, str\n"
" the id or the name of the variable.\n"
"\n"
"Raises\n"
"------\n"
"gum.NotFound\n"
" if the node is not found.\n"
"\n"
""},
{ "BayesNetFragment_uninstallNode", _wrap_BayesNetFragment_uninstallNode, METH_VARARGS, "\n"
"BayesNetFragment_uninstallNode(BayesNetFragment self, gum::NodeId id)\n"
"BayesNetFragment_uninstallNode(BayesNetFragment self, std::string const & name)\n"
"\n"
"Remove a node from the fragment. The fragment can become inconsistant.\n"
"\n"
"Parameters\n"
"----------\n"
"n : int, str\n"
" the id or the name of the variable.\n"
"\n"
"Raises\n"
"------\n"
"gum.NotFound\n"
" if the node is not found.\n"
"\n"
""},
{ "BayesNetFragment_installMarginal", _wrap_BayesNetFragment_installMarginal, METH_VARARGS, "\n"
"BayesNetFragment_installMarginal(BayesNetFragment self, gum::NodeId id, Potential pot)\n"
"BayesNetFragment_installMarginal(BayesNetFragment self, std::string const & name, Potential pot)\n"
"\n"
"Install a local marginal for a node. Doing so, it removes the parents of the node in the fragment.\n"
"\n"
"Parameters\n"
"----------\n"
"n : int, str\n"
" the id or the name of the variable.\n"
"pot : Potential\n"
" the Potential (marginal) to install\n"
"\n"
"Raises\n"
"------\n"
"gum.NotFound\n"
" if the node is not found.\n"
"\n"
""},
{ "BayesNetFragment_installCPT", _wrap_BayesNetFragment_installCPT, METH_VARARGS, "\n"
"BayesNetFragment_installCPT(BayesNetFragment self, gum::NodeId id, Potential pot)\n"
"BayesNetFragment_installCPT(BayesNetFragment self, std::string const & name, Potential pot)\n"
"\n"
"Install a local CPT for a node. Doing so, it changes the parents of the node in the fragment.\n"
"\n"
"Parameters\n"
"----------\n"
"n : int, str\n"
" the id or the name of the variable.\n"
"pot : Potential\n"
" the Potential to install\n"
"\n"
"Raises\n"
"------\n"
"gum.NotFound\n"
" if the node is not found.\n"
"\n"
""},
{ "BayesNetFragment_uninstallCPT", _wrap_BayesNetFragment_uninstallCPT, METH_VARARGS, "\n"
"BayesNetFragment_uninstallCPT(BayesNetFragment self, gum::NodeId id)\n"
"BayesNetFragment_uninstallCPT(BayesNetFragment self, std::string const & name)\n"
"\n"
"Remove a local CPT. The fragment can become inconsistant.\n"
"\n"
"Parameters\n"
"----------\n"
"n : int, str\n"
" the id or the name of the variable.\n"
"\n"
"Raises\n"
"------\n"
"gum.NotFound\n"
" if the node is not found.\n"
"\n"
""},
{ "BayesNetFragment_checkConsistency", _wrap_BayesNetFragment_checkConsistency, METH_VARARGS, "\n"
"BayesNetFragment_checkConsistency(BayesNetFragment self, gum::NodeId id) -> bool\n"
"BayesNetFragment_checkConsistency(BayesNetFragment self, std::string const & name) -> bool\n"
"BayesNetFragment_checkConsistency(BayesNetFragment self) -> bool\n"
"\n"
"If a variable is added to the fragment but not its parents, there is no CPT consistant for this variable. This function checks the consistency for a variable of for all.\n"
"\n"
"Parameters\n"
"----------\n"
"\n"
"n : int, str (optional)\n"
" the id or the name of the variable. If no argument, the function checks all the variables.\n"
"\n"
"Returns\n"
"-------\n"
"boolean\n"
" True if the variable(s) is consistant.\n"
"\n"
"Raises\n"
"------\n"
"gum.NotFound\n"
" if the node is not found.\n"
"\n"
""},
{ "BayesNetFragment_nodes", _wrap_BayesNetFragment_nodes, METH_O, "\n"
"BayesNetFragment_nodes(BayesNetFragment self) -> PyObject *\n"
......@@ -9506,7 +9506,7 @@ class BayesNet(IBayesNet):
name : str
the variable name
nbrmod : int
the numbre of modalities for the new variable
the number of modalities for the new variable
id : int
the variable forced id in the pyAgrum.BayesNet
......@@ -9520,7 +9520,7 @@ class BayesNet(IBayesNet):
gum.DuplicateLabel
If variable.name() is already used in this pyAgrum.BayesNet.
gum.NotAllowed
If nbrmod<2
If nbrmod is less than 2
gum.DuplicateElement
If id is already used.
......@@ -10672,8 +10672,15 @@ def BayesNet_fastPrototype(dotlike: "std::string const &", domainSize: "gum::Siz
class BayesNetFragment(IBayesNet, ):
r"""
Proxy of C++ gum::BayesNetFragment< double > class.
Proxy of C++ gum::BayesNetFragment< double > class.
BayesNetFragment represents a part of a Bayesian Network (subset of nodes). By default, the arcs and the CPTs are the same as the BN but local CPTs can be build to express different local dependencies. All the non local CPTs are not copied. Therefore a BayesNetFragment is a light object.
BayesNetFragment(BayesNet bn) -> BayesNetFragment
Parameters:
* **bn** (*pyAgrum.BayesNet*) -- the bn refered by the fragment
"""
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
......@@ -10848,6 +10855,14 @@ class BayesNetFragment(IBayesNet, ):
r"""
isInstalledNode(BayesNetFragment self, gum::NodeId id) -> bool
isInstalledNode(BayesNetFragment self, std::string const & name) -> bool
Check if a node is in the fragment
Parameters
----------
n : int, str
the id or the name of the variable.
"""
return _pyAgrum.BayesNetFragment_isInstalledNode(self, *args)
......@@ -10855,6 +10870,21 @@ class BayesNetFragment(IBayesNet, ):
r"""
installNode(BayesNetFragment self, gum::NodeId id)
installNode(BayesNetFragment self, std::string const & name)
Add a node to the fragment. The arcs that can be added between installed nodes are created.
No specific CPT are created. Then either the parents of the node are already in the fragment
and the node is consistant, or the parents are not in the fragment and the node is not consistant.
Parameters
----------
n : int, str
the id or the name of the variable.
Raises
------
gum.NotFound
if the node is not found.
"""
return _pyAgrum.BayesNetFragment_installNode(self, *args)
......@@ -10862,6 +10892,19 @@ class BayesNetFragment(IBayesNet, ):
r"""
installAscendants(BayesNetFragment self, gum::NodeId id)
installAscendants(BayesNetFragment self, std::string const & name)
Add the variable and all its ascendants in the fragment. No inconsistant node are created.
Parameters
----------
n : int, str
the id or the name of the variable.
Raises
------
gum.NotFound
if the node is not found.
"""
return _pyAgrum.BayesNetFragment_installAscendants(self, *args)
......@@ -10869,6 +10912,19 @@ class BayesNetFragment(IBayesNet, ):
r"""
uninstallNode(BayesNetFragment self, gum::NodeId id)
uninstallNode(BayesNetFragment self, std::string const & name)
Remove a node from the fragment. The fragment can become inconsistant.
Parameters
----------
n : int, str
the id or the name of the variable.
Raises
------
gum.NotFound
if the node is not found.
"""
return _pyAgrum.BayesNetFragment_uninstallNode(self, *args)
......@@ -10876,6 +10932,21 @@ class BayesNetFragment(IBayesNet, ):
r"""
installMarginal(BayesNetFragment self, gum::NodeId id, Potential pot)
installMarginal(BayesNetFragment self, std::string const & name, Potential pot)
Install a local marginal for a node. Doing so, it removes the parents of the node in the fragment.
Parameters
----------
n : int, str
the id or the name of the variable.
pot : Potential
the Potential (marginal) to install
Raises
------
gum.NotFound
if the node is not found.
"""
return _pyAgrum.BayesNetFragment_installMarginal(self, *args)
......@@ -10883,6 +10954,21 @@ class BayesNetFragment(IBayesNet, ):
r"""
installCPT(BayesNetFragment self, gum::NodeId id, Potential pot)
installCPT(BayesNetFragment self, std::string const & name, Potential pot)
Install a local CPT for a node. Doing so, it changes the parents of the node in the fragment.
Parameters
----------
n : int, str
the id or the name of the variable.
pot : Potential
the Potential to install
Raises
------
gum.NotFound
if the node is not found.
"""
return _pyAgrum.BayesNetFragment_installCPT(self, *args)
......@@ -10890,6 +10976,19 @@ class BayesNetFragment(IBayesNet, ):
r"""
uninstallCPT(BayesNetFragment self, gum::NodeId id)
uninstallCPT(BayesNetFragment self, std::string const & name)
Remove a local CPT. The fragment can become inconsistant.
Parameters
----------
n : int, str
the id or the name of the variable.
Raises
------
gum.NotFound
if the node is not found.
"""
return _pyAgrum.BayesNetFragment_uninstallCPT(self, *args)
......@@ -10898,6 +10997,25 @@ class BayesNetFragment(IBayesNet, ):
checkConsistency(BayesNetFragment self, gum::NodeId id) -> bool
checkConsistency(BayesNetFragment self, std::string const & name) -> bool
checkConsistency(BayesNetFragment self) -> bool
If a variable is added to the fragment but not its parents, there is no CPT consistant for this variable. This function checks the consistency for a variable of for all.
Parameters
----------
n : int, str (optional)
the id or the name of the variable. If no argument, the function checks all the variables.
Returns
-------
boolean
True if the variable(s) is consistant.
Raises
------
gum.NotFound
if the node is not found.
"""
return _pyAgrum.BayesNetFragment_checkConsistency(self, *args)
......
......@@ -123438,7 +123438,7 @@ static PyMethodDef SwigMethods[] = {
"name : str \n"
" the variable name\n"
"nbrmod : int\n"
" the numbre of modalities for the new variable\n"
" the number of modalities for the new variable\n"
"id : int\n"
" the variable forced id in the pyAgrum.BayesNet\n"
"\n"
......@@ -123452,7 +123452,7 @@ static PyMethodDef SwigMethods[] = {
"gum.DuplicateLabel\n"
" If variable.name() is already used in this pyAgrum.BayesNet.\n"
"gum.NotAllowed\n"
" If nbrmod<2\n"
" If nbrmod is less than 2\n"
"gum.DuplicateElement\n"
" If id is already used.\n"
"\n"
......@@ -124507,35 +124507,146 @@ static PyMethodDef SwigMethods[] = {
{ "BayesNetFragment_isInstalledNode", _wrap_BayesNetFragment_isInstalledNode, METH_VARARGS, "\n"
"BayesNetFragment_isInstalledNode(BayesNetFragment self, gum::NodeId id) -> bool\n"
"BayesNetFragment_isInstalledNode(BayesNetFragment self, std::string const & name) -> bool\n"
"\n"
"Check if a node is in the fragment\n"
"\n"
"Parameters\n"
"----------\n"
"n : int, str\n"
" the id or the name of the variable.\n"
"\n"
""},
{ "BayesNetFragment_installNode", _wrap_BayesNetFragment_installNode, METH_VARARGS, "\n"
"BayesNetFragment_installNode(BayesNetFragment self, gum::NodeId id)\n"
"BayesNetFragment_installNode(BayesNetFragment self, std::string const & name)\n"
"\n"
"Add a node to the fragment. The arcs that can be added between installed nodes are created.\n"
"No specific CPT are created. Then either the parents of the node are already in the fragment \n"
"and the node is consistant, or the parents are not in the fragment and the node is not consistant.\n"
"\n"
"Parameters\n"
"----------\n"
"n : int, str\n"
" the id or the name of the variable.\n"
"\n"
"Raises\n"
"------\n"
"gum.NotFound\n"
" if the node is not found.\n"
"\n"
""},
{ "BayesNetFragment_installAscendants", _wrap_BayesNetFragment_installAscendants, METH_VARARGS, "\n"
"BayesNetFragment_installAscendants(BayesNetFragment self, gum::NodeId id)\n"
"BayesNetFragment_installAscendants(BayesNetFragment self, std::string const & name)\n"
"\n"
"Add the variable and all its ascendants in the fragment. No inconsistant node are created.\n"
"\n"
"Parameters\n"
"----------\n"
"n : int, str\n"
" the id or the name of the variable.\n"
"\n"
"Raises\n"
"------\n"
"gum.NotFound\n"
" if the node is not found.\n"
"\n"
""},
{ "BayesNetFragment_uninstallNode", _wrap_BayesNetFragment_uninstallNode, METH_VARARGS, "\n"
"BayesNetFragment_uninstallNode(BayesNetFragment self, gum::NodeId id)\n"
"BayesNetFragment_uninstallNode(BayesNetFragment self, std::string const & name)\n"
"\n"
"Remove a node from the fragment. The fragment can become inconsistant.\n"
"\n"
"Parameters\n"
"----------\n"
"n : int, str\n"
" the id or the name of the variable.\n"
"\n"
"Raises\n"
"------\n"
"gum.NotFound\n"
" if the node is not found.\n"
"\n"
""},
{ "BayesNetFragment_installMarginal", _wrap_BayesNetFragment_installMarginal, METH_VARARGS, "\n"
"BayesNetFragment_installMarginal(BayesNetFragment self, gum::NodeId id, Potential pot)\n"
"BayesNetFragment_installMarginal(BayesNetFragment self, std::string const & name, Potential pot)\n"
"\n"
"Install a local marginal for a node. Doing so, it removes the parents of the node in the fragment.\n"
"\n"
"Parameters\n"
"----------\n"
"n : int, str\n"
" the id or the name of the variable.\n"
"pot : Potential\n"
" the Potential (marginal) to install\n"
"\n"
"Raises\n"
"------\n"
"gum.NotFound\n"
" if the node is not found.\n"
"\n"
""},
{ "BayesNetFragment_installCPT", _wrap_BayesNetFragment_installCPT, METH_VARARGS, "\n"
"BayesNetFragment_installCPT(BayesNetFragment self, gum::NodeId id, Potential pot)\n"
"BayesNetFragment_installCPT(BayesNetFragment self, std::string const & name, Potential pot)\n"
"\n"
"Install a local CPT for a node. Doing so, it changes the parents of the node in the fragment.\n"
"\n"
"Parameters\n"
"----------\n"
"n : int, str\n"
" the id or the name of the variable.\n"
"pot : Potential\n"
" the Potential to install\n"
"\n"
"Raises\n"
"------\n"
"gum.NotFound\n"
" if the node is not found.\n"
"\n"
""},
{ "BayesNetFragment_uninstallCPT", _wrap_BayesNetFragment_uninstallCPT, METH_VARARGS, "\n"
"BayesNetFragment_uninstallCPT(BayesNetFragment self, gum::NodeId id)\n"
"BayesNetFragment_uninstallCPT(BayesNetFragment self, std::string const & name)\n"