![]() |
aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
|
Class template representing a Credal Network. More...
#include <agrum/CN/credalNet.h>
Public Types | |
| enum class | NodeType : char { Precise , Credal , Vacuous , Indic } |
| NodeType to speed-up computations in some algorithms. More... | |
Public Member Functions | |
| void | saveBNsMinMax (std::string_view min_path, std::string_view max_path) |
| If this CredalNet was built over a perturbed BayesNet, one can save the intervals as two BayesNet. | |
| std::string | toString () const |
| void | computeBinaryCPTMinMax () |
| Used with binary networks to speed-up L2U inference. | |
Constructors / Destructors | |
| CredalNet () | |
| Constructor used to create a CredalNet step by step, i.e. | |
| CredalNet (std::string_view src_min_num, std::string_view src_max_den="") | |
| Constructor for interval defined credal network which takes 2 BayesNet file path. | |
| CredalNet (const BayesNet< GUM_SCALAR > &src_min_num, const BayesNet< GUM_SCALAR > &src_max_den=BayesNet< GUM_SCALAR >()) | |
| Constructor for interval defined credal network which takes 2 BayesNet. | |
| ~CredalNet () | |
| Destructor. | |
Credal network creation | |
| NodeId | addVariable (std::string_view name, const Size &card) |
| Adds a discrete node into the network. | |
| void | addArc (const NodeId &tail, const NodeId &head) |
| Adds an arc between two nodes. | |
| void | setCPTs (const NodeId &id, const std::vector< std::vector< std::vector< GUM_SCALAR > > > &cpt) |
| Set the vertices of the credal sets ( all of the conditionals ) of a given node | |
| void | setCPT (const NodeId &id, const Size &entry, const std::vector< std::vector< GUM_SCALAR > > &cpt) |
| Set the vertices of one credal set of a given node ( any instantiation index ) | |
| void | setCPT (const NodeId &id, Instantiation ins, const std::vector< std::vector< GUM_SCALAR > > &cpt) |
| Set the vertices of one credal set of a given node ( any instantiation ) | |
| void | fillConstraints (const NodeId &id, const std::vector< GUM_SCALAR > &lower, const std::vector< GUM_SCALAR > &upper) |
| Set the interval constraints of the credal sets of a given node (all instantiations ) | |
| void | fillConstraint (const NodeId &id, const Idx &entry, const std::vector< GUM_SCALAR > &lower, const std::vector< GUM_SCALAR > &upper) |
| Set the interval constraints of a credal set of a given node ( from an instantiation index ) | |
| void | fillConstraint (const NodeId &id, Instantiation ins, const std::vector< GUM_SCALAR > &lower, const std::vector< GUM_SCALAR > &upper) |
| Set the interval constraints of a credal sets of a given node ( from an instantiation ) | |
| Instantiation | instantiation (const NodeId &id) |
Get an Instantiation from a node id, useful to fill the constraints of the network | |
| Size | domainSize (const NodeId &id) |
| Get the cardinality of a node | |
Public manipulation methods | |
| void | bnToCredal (GUM_SCALAR beta, bool oneNet, bool keepZeroes) |
| Perturbates the BayesNet provided as input for this CredalNet by generating intervals instead of point probabilities and then computes each vertex of each credal set. | |
| void | bnToCredal (GUM_SCALAR beta, bool oneNet) |
| Perturbates the BayesNet provided as input for this CredalNet by generating intervals instead of point probabilities and then computes each vertex of each credal set. | |
| void | intervalToCredalWithFiles () |
| void | intervalToCredal () |
| Computes the vertices of each credal set according to their interval definition (uses lrs). | |
| void | lagrangeNormalization () |
| Normalize counts of a BayesNet storing counts of each events such that no probability is 0. | |
| void | idmLearning (const Idx s=0, const bool keepZeroes=false) |
| Learns parameters from a BayesNet storing counts of events. | |
| void | approximatedBinarization () |
| Approximate binarization. | |
Getters and setters | |
| const BayesNet< GUM_SCALAR > & | src_bn () const |
| const BayesNet< GUM_SCALAR > & | current_bn () const |
| const NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > > & | credalNet_currentCpt () const |
| const NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > > & | credalNet_srcCpt () const |
| NodeType | currentNodeType (const NodeId &id) const |
| NodeType | nodeType (const NodeId &id) const |
| const GUM_SCALAR & | epsilonMin () const |
| const GUM_SCALAR & | epsilonMax () const |
| const GUM_SCALAR & | epsilonMean () const |
| bool | isSeparatelySpecified () const |
| bool | hasComputedBinaryCPTMinMax () const |
| const std::vector< std::vector< GUM_SCALAR > > & | get_binaryCPT_min () const |
| Used with binary networks to speed-up L2U inference. | |
| const std::vector< std::vector< GUM_SCALAR > > & | get_binaryCPT_max () const |
| Used with binary networks to speed-up L2U inference. | |
Private Member Functions | |
| void | _sort_varType_ () |
| Set the NodeType of each node | |
| int | _find_dNode_card_ (const std::vector< std::vector< std::vector< GUM_SCALAR > > > &var_cpt) const |
| void | _intervalToCredal_ () |
| Computes the vertices of each credal set according to their interval definition (does not use lrs). | |
| void | _initParams_ () |
| Initialize private constant variables after the Constructor has been called. | |
| void | _initCNNets_ (std::string_view src_min_num, std::string_view src_max_den) |
| Initialize private BayesNet variables after the Constructor has been called. | |
| void | _initCNNets_ (const BayesNet< GUM_SCALAR > &src_min_num, const BayesNet< GUM_SCALAR > &src_max_den) |
| Initialize private BayesNet variables after the Constructor has been called. | |
| void | _bnCopy_ (BayesNet< GUM_SCALAR > &bn_dest) |
| void | _H2Vlrs_ (const std::vector< std::vector< GUM_SCALAR > > &h_rep, std::vector< std::vector< GUM_SCALAR > > &v_rep) const |
Private Attributes | |
| GUM_SCALAR | _precisionC_ |
| 1e6 by default, used by fracC as precision. | |
| GUM_SCALAR | _deltaC_ |
| 5 by default, used by fracC as number of decimals. | |
| GUM_SCALAR | _epsilonMin_ |
| The lowest perturbation of the BayesNet provided as input for this CredalNet. | |
| GUM_SCALAR | _epsilonMax_ |
| The highest perturbation of the BayesNet provided as input for this CredalNet. | |
| GUM_SCALAR | _epsilonMoy_ |
| The average perturbation of the BayesNet provided as input for this CredalNet. | |
| GUM_SCALAR | _epsRedund_ |
| Value under which a decimal number is considered to be zero when computing redundant vertices. | |
| GUM_SCALAR | _epsF_ |
| Value under which a decimal number is considered to be zero when using farey. | |
| GUM_SCALAR | _denMax_ |
| Highest possible denominator allowed when using farey. | |
| GUM_SCALAR | _precision_ |
| Precision used by frac. | |
| bool | _separatelySpecified_ |
TRUE if this CredalNet is separately and interval specified, FALSE otherwise. | |
| BayesNet< GUM_SCALAR > | _src_bn_ |
| Original BayesNet (used as a DAG). | |
| BayesNet< GUM_SCALAR > | _src_bn_min_ |
| BayesNet used to store lower probabilities. | |
| BayesNet< GUM_SCALAR > | _src_bn_max_ |
| BayesNet used to store upper probabilities. | |
| BayesNet< GUM_SCALAR > * | _current_bn_ |
| Up-to-date BayesNet (used as a DAG). | |
| NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > > | _credalNet_src_cpt_ |
| This CredalNet original CPTs. | |
| NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > > * | _credalNet_current_cpt_ |
| This CredalNet up-to-date CPTs. | |
| NodeProperty< std::vector< NodeId > > | _var_bits_ |
| Corresponding bits of each variable. | |
| NodeProperty< NodeType > | _original_nodeType_ |
| The NodeType of each node from the ORIGINAL network. | |
| NodeProperty< NodeType > * | _current_nodeType_ |
| The NodeType of each node from the up-to-date network. | |
| bool | _hasComputedBinaryCPTMinMax_ |
| Used by L2U, to know if lower and upper probabilities over the second modality has been stored in order to speed-up the algorithm. | |
| std::vector< std::vector< GUM_SCALAR > > | _binCptMin_ |
| Used with binary networks to speed-up L2U inference. | |
| std::vector< std::vector< GUM_SCALAR > > | _binCptMax_ |
| Used with binary networks to speed-up L2U inference. | |
Class template representing a Credal Network.
| GUM_SCALAR | A floating type ( float, GUM_SCALAR, long GUM_SCALAR ... ). |
Definition at line 97 of file credalNet.h.
|
strong |
NodeType to speed-up computations in some algorithms.
| Enumerator | |
|---|---|
| Precise | |
| Credal | |
| Vacuous | |
| Indic | |
Definition at line 100 of file credalNet.h.
| gum::credal::CredalNet< GUM_SCALAR >::CredalNet | ( | ) |
Constructor used to create a CredalNet step by step, i.e.
node by node, arc by arc, manually filling tensors.
Definition at line 55 of file credalNet_tpl.h.
References CredalNet(), _initParams_(), _src_bn_, _src_bn_max_, and _src_bn_min_.
Referenced by CredalNet(), CredalNet(), CredalNet(), and ~CredalNet().
| gum::credal::CredalNet< GUM_SCALAR >::CredalNet | ( | std::string_view | src_min_num, |
| std::string_view | src_max_den = "" ) |
Constructor for interval defined credal network which takes 2 BayesNet file path.
One can also provide a single BayesNet to perturb it's probability distributions into credal sets according to another BayesNet containing the amount cases, for each node, of each parent instantiation met during learning, i.e. \( p(X = 0 \mid pa(X) = j) = N_{pa(X) = j} \).
| src_min_num | The path to a BayesNet which contains lower probabilities. |
| src_max_den | The ( optional ) path to a BayesNet which contains upper probabilities. |
Definition at line 413 of file credalNet_tpl.h.
References CredalNet(), _initCNNets_(), and _initParams_().
| gum::credal::CredalNet< GUM_SCALAR >::CredalNet | ( | const BayesNet< GUM_SCALAR > & | src_min_num, |
| const BayesNet< GUM_SCALAR > & | src_max_den = BayesNet< GUM_SCALAR >() ) |
Constructor for interval defined credal network which takes 2 BayesNet.
One can also provide a single BayesNet in order to perturb it's probability distributions into credal sets according to another BayesNet containing the number of cases, for each node, of each parent instantiation met during learning, i.e. \( p(X = 0 \mid pa(X) = j) = N_{pa(X) = j} \).
| src_min_num | The BayesNet which contains lower probabilities. |
| src_max_den | The ( optional ) BayesNet which contains upper probabilities. |
Definition at line 421 of file credalNet_tpl.h.
References CredalNet(), _initCNNets_(), and _initParams_().
| gum::credal::CredalNet< GUM_SCALAR >::~CredalNet | ( | ) |
Destructor.
Definition at line 430 of file credalNet_tpl.h.
References CredalNet(), _credalNet_current_cpt_, _current_bn_, and _current_nodeType_.
|
private |
Copy the up-to-date BayesNet associated with this CredalNet. Since all we care about is the DAG, only arcs are copied. Because the order with which arcs are created is important, the function iterates over the CPTs variables to be sure parent order stays the same from a net to it's copy.
| bn_dest | The reference to the new copy |
Definition at line 1419 of file credalNet_tpl.h.
References _current_bn_, and _src_bn_.
|
private |
| var_cpt | The reference to a node CPT which may need a Decision Node. |
Definition at line 1407 of file credalNet_tpl.h.
|
private |
| h_rep | A constant reference to the H-representation of a credal set. |
| v_rep | A reference to the V-representation of the same credal set. |
Definition at line 1489 of file credalNet_tpl.h.
References _denMax_, _epsF_, _epsRedund_, gum::dispatchRangeToThreads(), gum::threadsSTL::ThreadExecutor::execute(), gum::Rational< GUM_SCALAR >::farey(), gum::getNumberOfThreads(), gum::getUniqueFileName(), GUM_ERROR, and gum::threadsSTL::ThreadExecutor::nbRunningThreadsExecutors().
Referenced by intervalToCredalWithFiles().
|
private |
Initialize private BayesNet variables after the Constructor has been called.
Definition at line 1397 of file credalNet_tpl.h.
References _src_bn_, _src_bn_max_, and _src_bn_min_.
|
private |
Initialize private BayesNet variables after the Constructor has been called.
Definition at line 1380 of file credalNet_tpl.h.
References _src_bn_, _src_bn_max_, _src_bn_min_, and gum::BIFReader< GUM_SCALAR >::proceed().
Referenced by CredalNet(), and CredalNet().
|
private |
Initialize private constant variables after the Constructor has been called.
Definition at line 1353 of file credalNet_tpl.h.
References _credalNet_current_cpt_, _current_bn_, _current_nodeType_, _deltaC_, _denMax_, _epsF_, _epsilonMax_, _epsilonMin_, _epsilonMoy_, _epsRedund_, _hasComputedBinaryCPTMinMax_, _precision_, and _precisionC_.
Referenced by CredalNet(), CredalNet(), and CredalNet().
|
private |
Computes the vertices of each credal set according to their interval definition (does not use lrs).
Only works with credal sets defined such that when one modality reach it's upper probability, all others are at their lowest.
Called by bnToCredal and idmLearning.
Definition at line 687 of file credalNet_tpl.h.
References _credalNet_src_cpt_, _separatelySpecified_, _sort_varType_(), _src_bn_, _src_bn_max_, _src_bn_min_, GUM_ERROR, and gum::Instantiation::setFirst().
Referenced by bnToCredal(), and idmLearning().
|
private |
Set the NodeType of each node
Definition at line 1694 of file credalNet_tpl.h.
References _credalNet_current_cpt_, _credalNet_src_cpt_, _current_bn_, _current_nodeType_, _original_nodeType_, _src_bn_, Credal, gum::HashTable< Key, Val >::exists(), gum::HashTable< Key, Val >::insert(), Precise, and Vacuous.
Referenced by _intervalToCredal_(), approximatedBinarization(), intervalToCredal(), and intervalToCredalWithFiles().
| void gum::credal::CredalNet< GUM_SCALAR >::addArc | ( | const NodeId & | tail, |
| const NodeId & | head ) |
Adds an arc between two nodes.
Definition at line 82 of file credalNet_tpl.h.
References _src_bn_, _src_bn_max_, and _src_bn_min_.
| NodeId gum::credal::CredalNet< GUM_SCALAR >::addVariable | ( | std::string_view | name, |
| const Size & | card ) |
Adds a discrete node into the network.
| name | The name of the discrete variable to be added |
| card | The cardinality of the variable |
NodeId of the variable in the network Definition at line 66 of file credalNet_tpl.h.
References _src_bn_, _src_bn_max_, _src_bn_min_, and GUM_ERROR.
| void gum::credal::CredalNet< GUM_SCALAR >::approximatedBinarization | ( | ) |
Approximate binarization.
Each bit has a lower and upper probability which is the lowest - resp. highest - over all vertices of the credal set. Enlarge the original credal sets and may induce huge imprecision.
Definition at line 957 of file credalNet_tpl.h.
References _credalNet_current_cpt_, _credalNet_src_cpt_, _current_bn_, _current_nodeType_, _sort_varType_(), _src_bn_, _var_bits_, computeBinaryCPTMinMax(), current_bn(), Indic, gum::HashTable< Key, Val >::insert(), gum::int2Pow(), gum::Instantiation::pos(), gum::Instantiation::setFirst(), gum::superiorPow(), and gum::Instantiation::val().
| void gum::credal::CredalNet< GUM_SCALAR >::bnToCredal | ( | GUM_SCALAR | beta, |
| bool | oneNet ) |
Perturbates the BayesNet provided as input for this CredalNet by generating intervals instead of point probabilities and then computes each vertex of each credal set.
The perturbations are done according to the number of cases met for each node and each of it's parent instantiation, i.e. \( \epsilon =
*\beta^{ln(N_{pa(X) = j} + 1)} \) is the imprecision introduced which leads to \( \underline{p}(X = i \mid pa(X) = j) = (1 - \epsilon) p(X = i
*\mid pa(X) = j) \) and \( \overline{p}(X = i \mid pa(X) = j)
*=\underline{p}(X =i \mid pa(X) = j) + \epsilon \). Use this method when using a single BayesNet storing counts of events with oneNet set to TRUE or when using two BayesNet, one with lower probabilities and one with upper probabilities, with oneNet set to FALSE.
| beta | The beta used to perturbate the network. \( 0 \leq \beta *\leq 1 \). |
| oneNet | Boolean used as a flag. Set to TRUE if one BayesNet if provided with counts, to FALSE if two BayesNet are provided; one with probabilities (the lower net) and one with denominators over the first modalities (the upper net). |
| keepZeroes | Boolean used as a flag as whether or not - respectively TRUE or FALSE - we keep zeroes as zeroes. Default is FALSE, i.e. zeroes are not kept. |
Definition at line 442 of file credalNet_tpl.h.
References bnToCredal().
| void gum::credal::CredalNet< GUM_SCALAR >::bnToCredal | ( | GUM_SCALAR | beta, |
| bool | oneNet, | ||
| bool | keepZeroes ) |
Perturbates the BayesNet provided as input for this CredalNet by generating intervals instead of point probabilities and then computes each vertex of each credal set.
The perturbations are done according to the number of cases met for each node and each of it's parent instantiation, i.e. \( \epsilon =
*\beta^{ln(N_{pa(X) = j} + 1)} \) is the imprecision introduced which leads to \( \underline{p}(X = i \mid pa(X) = j) = (1 - \epsilon) p(X = i
*\mid pa(X) = j) \) and \( \overline{p}(X = i \mid pa(X) = j)
*=\underline{p}(X =i \mid pa(X) = j) + \epsilon \). Use this method when using a single BayesNet storing counts of events with oneNet set to TRUE or when using two BayesNet, one with lower probabilities and one with upper probabilities, with oneNet set to FALSE.
| beta | The beta used to perturbate the network. \( 0 \leq \beta *\leq 1 \). |
| oneNet | Boolean used as a flag. Set to TRUE if one BayesNet if provided with counts, to FALSE if two BayesNet are provided; one with probabilities (the lower net) and one with denominators over the first modalities (the upper net). |
| keepZeroes | Boolean used as a flag as whether or not - respectively TRUE or FALSE - we keep zeroes as zeroes. Default is FALSE, i.e. zeroes are not kept. |
Definition at line 447 of file credalNet_tpl.h.
References _epsilonMax_, _epsilonMin_, _epsilonMoy_, _epsRedund_, _intervalToCredal_(), _src_bn_, _src_bn_max_, _src_bn_min_, GUM_ERROR, gum::Instantiation::setFirst(), and src_bn().
Referenced by bnToCredal().
| void gum::credal::CredalNet< GUM_SCALAR >::computeBinaryCPTMinMax | ( | ) |
Used with binary networks to speed-up L2U inference.
Store the lower and upper probabilities of each node X over the "true" modality, i.e. respectively \( \underline{p}(X = 1 \mid pa(X) = j) \) and \( \overline{p}(X = 1 \mid pa(X) = j) \).
Definition at line 1247 of file credalNet_tpl.h.
References _binCptMax_, _binCptMin_, _hasComputedBinaryCPTMinMax_, credalNet_currentCpt(), and current_bn().
Referenced by approximatedBinarization().
| const NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > > & gum::credal::CredalNet< GUM_SCALAR >::credalNet_currentCpt | ( | ) | const |
Definition at line 1209 of file credalNet_tpl.h.
References _credalNet_current_cpt_, and _credalNet_src_cpt_.
Referenced by computeBinaryCPTMinMax(), and gum::credal::VarMod2BNsMap< GUM_SCALAR >::setCNet().
| const NodeProperty< std::vector< std::vector< std::vector< GUM_SCALAR > > > > & gum::credal::CredalNet< GUM_SCALAR >::credalNet_srcCpt | ( | ) | const |
Definition at line 1217 of file credalNet_tpl.h.
References _credalNet_src_cpt_.
| const BayesNet< GUM_SCALAR > & gum::credal::CredalNet< GUM_SCALAR >::current_bn | ( | ) | const |
Definition at line 1337 of file credalNet_tpl.h.
References _current_bn_, and _src_bn_.
Referenced by approximatedBinarization(), and computeBinaryCPTMinMax().
| CredalNet< GUM_SCALAR >::NodeType gum::credal::CredalNet< GUM_SCALAR >::currentNodeType | ( | const NodeId & | id | ) | const |
| id | The constant reference to the chosen NodeId |
Definition at line 1223 of file credalNet_tpl.h.
References _current_nodeType_, and _original_nodeType_.
| Size gum::credal::CredalNet< GUM_SCALAR >::domainSize | ( | const NodeId & | id | ) |
Get the cardinality of a node
| id | The NodeId of the node |
Definition at line 406 of file credalNet_tpl.h.
References _src_bn_.
| const GUM_SCALAR & gum::credal::CredalNet< GUM_SCALAR >::epsilonMax | ( | ) | const |
Definition at line 1296 of file credalNet_tpl.h.
References _epsilonMax_.
| const GUM_SCALAR & gum::credal::CredalNet< GUM_SCALAR >::epsilonMean | ( | ) | const |
Definition at line 1301 of file credalNet_tpl.h.
References _epsilonMoy_.
| const GUM_SCALAR & gum::credal::CredalNet< GUM_SCALAR >::epsilonMin | ( | ) | const |
Definition at line 1291 of file credalNet_tpl.h.
References _epsilonMin_.
| void gum::credal::CredalNet< GUM_SCALAR >::fillConstraint | ( | const NodeId & | id, |
| const Idx & | entry, | ||
| const std::vector< GUM_SCALAR > & | lower, | ||
| const std::vector< GUM_SCALAR > & | upper ) |
Set the interval constraints of a credal set of a given node ( from an instantiation index )
| id | The NodeId of the node |
| entry | The index of the instantiation excluding the given node ( only the parents are used to compute the index of the credal set ) |
| lower | The lower value for each probability in correct order |
| upper | The upper value for each probability in correct order |
You need to call intervalToCredal when done filling all constraints.
BayesNet (s) associated to this credal net ! ins to check variable order in the instantiation ( to get index ), therefore we pass it by value Definition at line 287 of file credalNet_tpl.h.
References _src_bn_, _src_bn_max_, _src_bn_min_, GUM_ERROR, and gum::Instantiation::setFirst().
Referenced by fillConstraint().
| void gum::credal::CredalNet< GUM_SCALAR >::fillConstraint | ( | const NodeId & | id, |
| Instantiation | ins, | ||
| const std::vector< GUM_SCALAR > & | lower, | ||
| const std::vector< GUM_SCALAR > & | upper ) |
Set the interval constraints of a credal sets of a given node ( from an instantiation )
| id | The NodeId of the node |
| ins | The Instantiation |
| lower | The lower value for each probability in correct order |
| upper | The upper value for each probability in correct order |
You need to call intervalToCredal when done filling all constraints.
BayesNet (s) associated to this credal net ! ins to check variable order in the instantiation ( to get index ), therefore we pass it by value Definition at line 334 of file credalNet_tpl.h.
References _src_bn_, gum::DiscreteVariable::domainSize(), fillConstraint(), gum::Instantiation::forgetMaster(), GUM_ERROR, gum::Instantiation::nbrDim(), gum::Instantiation::reorder(), gum::Instantiation::val(), gum::Instantiation::variable(), and gum::Instantiation::variablesSequence().
| void gum::credal::CredalNet< GUM_SCALAR >::fillConstraints | ( | const NodeId & | id, |
| const std::vector< GUM_SCALAR > & | lower, | ||
| const std::vector< GUM_SCALAR > & | upper ) |
Set the interval constraints of the credal sets of a given node (all instantiations )
| id | The NodeId of the node |
| lower | The lower value for each probability in correct order |
| upper | The upper value for each probability in correct order |
You need to call intervalToCredal when done filling all constraints.
BayesNet (s) associated to this credal net ! ins to check variable order in the instantiation ( to get index ), therefore we pass it by value Definition at line 274 of file credalNet_tpl.h.
References _src_bn_max_, _src_bn_min_, and GUM_ERROR.
| const std::vector< std::vector< GUM_SCALAR > > & gum::credal::CredalNet< GUM_SCALAR >::get_binaryCPT_max | ( | ) | const |
Used with binary networks to speed-up L2U inference.
Definition at line 1286 of file credalNet_tpl.h.
References _binCptMax_.
| const std::vector< std::vector< GUM_SCALAR > > & gum::credal::CredalNet< GUM_SCALAR >::get_binaryCPT_min | ( | ) | const |
Used with binary networks to speed-up L2U inference.
Definition at line 1280 of file credalNet_tpl.h.
References _binCptMin_.
| bool gum::credal::CredalNet< GUM_SCALAR >::hasComputedBinaryCPTMinMax | ( | ) | const |
TRUE if this CredalNet has called computeBinaryCPTMinMax() to speed-up inference with binary networks and L2U. This needs to be reworked as it is too easy to forget to call it and it can't be called within the inference engine (constness). Definition at line 1241 of file credalNet_tpl.h.
References _hasComputedBinaryCPTMinMax_.
| void gum::credal::CredalNet< GUM_SCALAR >::idmLearning | ( | const Idx | s = 0, |
| const bool | keepZeroes = false ) |
Learns parameters from a BayesNet storing counts of events.
Use this method when using a single BayesNet storing counts of events. IDM model if s > 0, standard point probability if s = 0 (default value if none precised).
| s | The IDM parameter. |
| keepZeroes | Boolean used as a flag as whether or not - respectively TRUE or FALSE - we keep zeroes as zeroes. Default is FALSE, i.e. zeroes are not kept. |
Definition at line 616 of file credalNet_tpl.h.
References _epsilonMax_, _epsilonMin_, _epsilonMoy_, _intervalToCredal_(), _src_bn_, _src_bn_max_, _src_bn_min_, GUM_ERROR, and gum::Instantiation::setFirst().
| Instantiation gum::credal::CredalNet< GUM_SCALAR >::instantiation | ( | const NodeId & | id | ) |
Get an Instantiation from a node id, useful to fill the constraints of the network
bnet accessors / shortcuts
| id | The NodeId we want an instantiation from |
Definition at line 401 of file credalNet_tpl.h.
References _src_bn_.
| void gum::credal::CredalNet< GUM_SCALAR >::intervalToCredal | ( | ) |
Computes the vertices of each credal set according to their interval definition (uses lrs).
Use this method when using two BayesNet, one with lower probabilities and one with upper probabilities.
Definition at line 781 of file credalNet_tpl.h.
References _credalNet_src_cpt_, _separatelySpecified_, _sort_varType_(), _src_bn_, _src_bn_max_, _src_bn_min_, gum::credal::LRSWrapper< GUM_SCALAR >::fillH(), gum::credal::LRSWrapper< GUM_SCALAR >::getOutput(), GUM_ERROR, gum::credal::LRSWrapper< GUM_SCALAR >::H2V(), gum::credal::LRSWrapper< GUM_SCALAR >::nextHInput(), gum::Instantiation::setFirst(), and gum::credal::LRSWrapper< GUM_SCALAR >::setUpH().
| void gum::credal::CredalNet< GUM_SCALAR >::intervalToCredalWithFiles | ( | ) |
Computes the vertices of each credal set according to their interval definition (uses lrs).
Use this method when using a single BayesNet storing counts of events.
Definition at line 834 of file credalNet_tpl.h.
References _credalNet_src_cpt_, _H2Vlrs_(), _separatelySpecified_, _sort_varType_(), _src_bn_, _src_bn_max_, _src_bn_min_, and gum::Instantiation::setFirst().
| bool gum::credal::CredalNet< GUM_SCALAR >::isSeparatelySpecified | ( | ) | const |
TRUE if this CredalNet is separately and interval specified, FALSE otherwise. Definition at line 1236 of file credalNet_tpl.h.
References _separatelySpecified_.
| void gum::credal::CredalNet< GUM_SCALAR >::lagrangeNormalization | ( | ) |
Normalize counts of a BayesNet storing counts of each events such that no probability is 0.
Use this method when using a single BayesNet storing counts of events. Lagrange normalization. This call is irreversible and modify counts stored by _src_bn_.
Doest not performs computations of the parameters but keeps normalized counts of events only. Call idmLearning to compute the probabilities (with any parameter value).
Definition at line 572 of file credalNet_tpl.h.
References _src_bn_, GUM_ERROR, and gum::Instantiation::setFirst().
| CredalNet< GUM_SCALAR >::NodeType gum::credal::CredalNet< GUM_SCALAR >::nodeType | ( | const NodeId & | id | ) | const |
| id | The constant reference to the chosen NodeId |
Definition at line 1231 of file credalNet_tpl.h.
References _original_nodeType_.
| void gum::credal::CredalNet< GUM_SCALAR >::saveBNsMinMax | ( | std::string_view | min_path, |
| std::string_view | max_path ) |
If this CredalNet was built over a perturbed BayesNet, one can save the intervals as two BayesNet.
to call after bnToCredal( GUM_SCALAR beta ) save a BN with lower probabilities and a BN with upper ones
| min_path | The path to save the BayesNet which contains the lower probabilities of each node X, i.e. \( \underline{p}(X = i \mid pa(X) = *j) *\). |
| max_path | The path to save the BayesNet which contains the upper probabilities of each node X, i.e. \( \overline{p}(X = i \mid pa(X) = *j) *\). |
Definition at line 925 of file credalNet_tpl.h.
References _src_bn_max_, _src_bn_min_, GUM_ERROR, GUM_SHOWERROR, and gum::BNWriter< GUM_SCALAR >::write().
| void gum::credal::CredalNet< GUM_SCALAR >::setCPT | ( | const NodeId & | id, |
| const Size & | entry, | ||
| const std::vector< std::vector< GUM_SCALAR > > & | cpt ) |
Set the vertices of one credal set of a given node ( any instantiation index )
| id | The NodeId of the node |
| entry | The index of the instantiation ( from 0 to K - 1 ) excluding the given node ( only the parents are used to compute the index of the credal set ) |
| cpt | The vertices of every credal set ( for each instantiation of the parents ) |
Use this with either LRSWrapper or LpInterface to get the vertices of a credal set represented by linear constraints.
BayesNet (s) associated to this credal net ! Definition at line 133 of file credalNet_tpl.h.
References _credalNet_src_cpt_, _src_bn_, GUM_ERROR, and gum::isCloseToOne().
| void gum::credal::CredalNet< GUM_SCALAR >::setCPT | ( | const NodeId & | id, |
| Instantiation | ins, | ||
| const std::vector< std::vector< GUM_SCALAR > > & | cpt ) |
Set the vertices of one credal set of a given node ( any instantiation )
| id | The NodeId of the node |
| ins | The Instantiation ( only the parents matter to find the credal set index ) |
| cpt | The vertices of every credal set ( for each instantiation of the parents ) |
Use this with either LRSWrapper or LpInterface to get the vertices of a credal set represented by linear constraints.
BayesNet (s) associated to this credal net !ins to check variable order in the instantiation ( to get index ), therefore we pass it by value Definition at line 186 of file credalNet_tpl.h.
References _credalNet_src_cpt_, _src_bn_, gum::DiscreteVariable::domainSize(), gum::Instantiation::forgetMaster(), GUM_ERROR, gum::isCloseToOne(), gum::Instantiation::nbrDim(), gum::Instantiation::reorder(), gum::Instantiation::val(), gum::Instantiation::variable(), and gum::Instantiation::variablesSequence().
| void gum::credal::CredalNet< GUM_SCALAR >::setCPTs | ( | const NodeId & | id, |
| const std::vector< std::vector< std::vector< GUM_SCALAR > > > & | cpt ) |
Set the vertices of the credal sets ( all of the conditionals ) of a given node
| id | The NodeId of the node |
| cpt | The vertices of every credal set ( for each instantiation of the parents ) |
BayesNet (s) associated to this credal net !First dimension is instantiation position ( from 0 to K - 1 ). Second is the credal set vertice index Third is the vertex
Definition at line 89 of file credalNet_tpl.h.
References _credalNet_src_cpt_, _src_bn_, GUM_ERROR, and gum::isCloseToOne().
| const BayesNet< GUM_SCALAR > & gum::credal::CredalNet< GUM_SCALAR >::src_bn | ( | ) | const |
Definition at line 1344 of file credalNet_tpl.h.
References _src_bn_.
Referenced by bnToCredal().
| std::string gum::credal::CredalNet< GUM_SCALAR >::toString | ( | ) | const |
Definition at line 1306 of file credalNet_tpl.h.
References _credalNet_current_cpt_, _credalNet_src_cpt_, _current_bn_, _src_bn_, gum::Instantiation::erase(), gum::Instantiation::forgetMaster(), and gum::Instantiation::setFirst().
|
private |
Used with binary networks to speed-up L2U inference.
Store the upper probabilities of each node X over the "true" modality, i.e. \(\overline{p}(X = 1 \mid pa(X) = j) \).
Definition at line 633 of file credalNet.h.
Referenced by computeBinaryCPTMinMax(), and get_binaryCPT_max().
|
private |
Used with binary networks to speed-up L2U inference.
Store the lower probabilities of each node X over the "true" modality, i.e. \(\underline{p}(X = 1 \mid pa(X) = j) \).
Definition at line 625 of file credalNet.h.
Referenced by computeBinaryCPTMinMax(), and get_binaryCPT_min().
|
private |
This CredalNet up-to-date CPTs.
Definition at line 606 of file credalNet.h.
Referenced by ~CredalNet(), _initParams_(), _sort_varType_(), approximatedBinarization(), credalNet_currentCpt(), and toString().
|
private |
This CredalNet original CPTs.
Definition at line 602 of file credalNet.h.
Referenced by _intervalToCredal_(), _sort_varType_(), approximatedBinarization(), credalNet_currentCpt(), credalNet_srcCpt(), intervalToCredal(), intervalToCredalWithFiles(), setCPT(), setCPT(), setCPTs(), and toString().
|
private |
Up-to-date BayesNet (used as a DAG).
Definition at line 599 of file credalNet.h.
Referenced by ~CredalNet(), _bnCopy_(), _initParams_(), _sort_varType_(), approximatedBinarization(), current_bn(), and toString().
|
private |
The NodeType of each node from the up-to-date network.
Definition at line 614 of file credalNet.h.
Referenced by ~CredalNet(), _initParams_(), _sort_varType_(), approximatedBinarization(), and currentNodeType().
|
private |
5 by default, used by fracC as number of decimals.
Definition at line 553 of file credalNet.h.
Referenced by _initParams_().
|
private |
Highest possible denominator allowed when using farey.
A value too high may lead to lrs being unable to find vertices.
Definition at line 580 of file credalNet.h.
Referenced by _H2Vlrs_(), and _initParams_().
|
private |
Value under which a decimal number is considered to be zero when using farey.
Definition at line 576 of file credalNet.h.
Referenced by _H2Vlrs_(), and _initParams_().
|
private |
The highest perturbation of the BayesNet provided as input for this CredalNet.
Definition at line 562 of file credalNet.h.
Referenced by _initParams_(), bnToCredal(), epsilonMax(), and idmLearning().
|
private |
The lowest perturbation of the BayesNet provided as input for this CredalNet.
Definition at line 558 of file credalNet.h.
Referenced by _initParams_(), bnToCredal(), epsilonMin(), and idmLearning().
|
private |
The average perturbation of the BayesNet provided as input for this CredalNet.
Definition at line 566 of file credalNet.h.
Referenced by _initParams_(), bnToCredal(), epsilonMean(), and idmLearning().
|
private |
Value under which a decimal number is considered to be zero when computing redundant vertices.
Definition at line 571 of file credalNet.h.
Referenced by _H2Vlrs_(), _initParams_(), and bnToCredal().
|
private |
Used by L2U, to know if lower and upper probabilities over the second modality has been stored in order to speed-up the algorithm.
Definition at line 618 of file credalNet.h.
Referenced by _initParams_(), computeBinaryCPTMinMax(), and hasComputedBinaryCPTMinMax().
|
private |
The NodeType of each node from the ORIGINAL network.
Definition at line 612 of file credalNet.h.
Referenced by _sort_varType_(), currentNodeType(), and nodeType().
|
private |
|
private |
1e6 by default, used by fracC as precision.
Definition at line 551 of file credalNet.h.
Referenced by _initParams_().
|
private |
TRUE if this CredalNet is separately and interval specified, FALSE otherwise.
Definition at line 588 of file credalNet.h.
Referenced by _intervalToCredal_(), intervalToCredal(), intervalToCredalWithFiles(), and isSeparatelySpecified().
|
private |
Original BayesNet (used as a DAG).
Is never modified.
Definition at line 591 of file credalNet.h.
Referenced by CredalNet(), _bnCopy_(), _initCNNets_(), _initCNNets_(), _intervalToCredal_(), _sort_varType_(), addArc(), addVariable(), approximatedBinarization(), bnToCredal(), current_bn(), domainSize(), fillConstraint(), fillConstraint(), idmLearning(), instantiation(), intervalToCredal(), intervalToCredalWithFiles(), lagrangeNormalization(), setCPT(), setCPT(), setCPTs(), src_bn(), and toString().
|
private |
BayesNet used to store upper probabilities.
Definition at line 596 of file credalNet.h.
Referenced by CredalNet(), _initCNNets_(), _initCNNets_(), _intervalToCredal_(), addArc(), addVariable(), bnToCredal(), fillConstraint(), fillConstraints(), idmLearning(), intervalToCredal(), intervalToCredalWithFiles(), and saveBNsMinMax().
|
private |
BayesNet used to store lower probabilities.
Definition at line 594 of file credalNet.h.
Referenced by CredalNet(), _initCNNets_(), _initCNNets_(), _intervalToCredal_(), addArc(), addVariable(), bnToCredal(), fillConstraint(), fillConstraints(), idmLearning(), intervalToCredal(), intervalToCredalWithFiles(), and saveBNsMinMax().
|
private |
Corresponding bits of each variable.
Definition at line 609 of file credalNet.h.
Referenced by approximatedBinarization().