![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
A dirichlet priori: computes its N'_ijk from a database. More...
#include <agrum/base/database/DirichletPriorFromDatabase.h>
Public Member Functions | |
Constructors / Destructors | |
| DirichletPriorFromDatabase (const DatabaseTable &learning_db, const DBRowGeneratorParser &prior_parser, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >()) | |
| default constructor | |
| DirichletPriorFromDatabase (const DirichletPriorFromDatabase &from) | |
| copy constructor | |
| DirichletPriorFromDatabase (DirichletPriorFromDatabase &&from) noexcept | |
| move constructor | |
| virtual DirichletPriorFromDatabase * | clone () const |
| virtual copy constructor | |
| virtual | ~DirichletPriorFromDatabase () |
| destructor | |
Operators | |
| DirichletPriorFromDatabase & | operator= (const DirichletPriorFromDatabase &from) |
| copy operator | |
| DirichletPriorFromDatabase & | operator= (DirichletPriorFromDatabase &&from) |
| move operator | |
Accessors / Modifiers | |
| PriorType | getType () const final |
| returns the type of the prior | |
| bool | isInformative () const final |
| indicates whether the prior is tensorly informative | |
| void | setWeight (double weight) final |
| sets the weight of the a prior(kind of effective sample size) | |
| virtual void | addJointPseudoCount (const IdCondSet &idset, std::vector< double > &counts) final |
| adds the prior to a counting vector corresponding to the idset | |
| void | addConditioningPseudoCount (const IdCondSet &idset, std::vector< double > &counts) final |
| adds the prior to a counting vectordefined over the right hand side of the idset | |
Accessors / Modifiers | |
| double | weight () const |
| returns the weight assigned to the prior | |
Protected Attributes | |
| double | weight_ {1.0} |
| the weight of the prior | |
| const DatabaseTable * | database_ |
| a reference to the database in order to have access to its variables | |
| Bijection< NodeId, std::size_t > | nodeId2columns_ |
| a mapping from the NodeIds of the variables to the indices of the columns in the database | |
A dirichlet priori: computes its N'_ijk from a database.
Definition at line 66 of file DirichletPriorFromDatabase.h.
| gum::learning::DirichletPriorFromDatabase::DirichletPriorFromDatabase | ( | const DatabaseTable & | learning_db, |
| const DBRowGeneratorParser & | prior_parser, | ||
| const Bijection< NodeId, std::size_t > & | nodeId2columns = Bijection< NodeId, std::size_t >() ) |
default constructor
| learning_db | the database from which learning is performed. This is useful to get access to the random variables |
| prior_parser | the parser used to parse the prior database |
| nodeId2Columns | a mapping from the ids of the nodes in the graphical model to the corresponding column in learning_db. This enables estimating from a database in which variable A corresponds to the 2nd column the parameters of a BN in which variable A has a NodeId of 5. An empty nodeId2Columns bijection means that the mapping is an identity, i.e., the value of a NodeId is equal to the index of the column in the DatabaseTable. |
| DatabaseError | The prior database may differ from the learning database, i.e., the prior may have more nodes than the learning one. However, a check is performed to ensure that the variables within the prior database that correspond to those in the learning database (they have the same names) are exactly identical. If this is not the case, then a DatabaseError exception is raised. |
Referenced by DirichletPriorFromDatabase(), DirichletPriorFromDatabase(), clone(), operator=(), and operator=().
| gum::learning::DirichletPriorFromDatabase::DirichletPriorFromDatabase | ( | const DirichletPriorFromDatabase & | from | ) |
|
noexcept |
|
virtual |
destructor
|
finalvirtual |
adds the prior to a counting vectordefined over the right hand side of the idset
Implements gum::learning::Prior.
References addConditioningPseudoCount().
Referenced by addConditioningPseudoCount().
|
finalvirtual |
adds the prior to a counting vector corresponding to the idset
adds the prior to an already created counting vector defined over the union of the variables on both the left and right hand side of the conditioning bar of the idset.
Implements gum::learning::Prior.
References addJointPseudoCount().
Referenced by addJointPseudoCount().
|
virtual |
virtual copy constructor
Implements gum::learning::Prior.
References DirichletPriorFromDatabase().
|
finalvirtual |
returns the type of the prior
Implements gum::learning::Prior.
|
finalvirtual |
indicates whether the prior is tensorly informative
Basically, only the NoPrior is uninformative. However, it may happen that, under some circumstances, an prior, which is usually not equal to the NoPrior, becomes equal to it (e.g., when the weight is equal to zero). In this case, if the prior can detect this case, it shall inform the classes that use it that it is temporarily uninformative. These classes will then be able to speed-up their code by avoiding to take into account the prior in their computations.
Implements gum::learning::Prior.
References isInformative().
Referenced by isInformative().
| DirichletPriorFromDatabase & gum::learning::DirichletPriorFromDatabase::operator= | ( | const DirichletPriorFromDatabase & | from | ) |
| DirichletPriorFromDatabase & gum::learning::DirichletPriorFromDatabase::operator= | ( | DirichletPriorFromDatabase && | from | ) |
|
finalvirtual |
sets the weight of the a prior(kind of effective sample size)
Reimplemented from gum::learning::Prior.
References setWeight(), and gum::learning::Prior::weight().
Referenced by setWeight().
|
inherited |
returns the weight assigned to the prior
Referenced by gum::learning::BDeuPrior::setEffectiveSampleSize(), gum::learning::BDeuPrior::setWeight(), gum::learning::DirichletPriorFromBN< GUM_SCALAR >::setWeight(), gum::learning::DirichletPriorFromDatabase::setWeight(), gum::learning::K2Prior::setWeight(), gum::learning::NoPrior::setWeight(), and setWeight().
|
protectedinherited |
|
protectedinherited |