aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::learning::DirichletPriorFromBN< GUM_SCALAR > Class Template Reference

A dirichlet priori: computes its N'_ijk from a database. More...

#include <agrum/base/database/DirichletPriorFromBN.h>

Inheritance diagram for gum::learning::DirichletPriorFromBN< GUM_SCALAR >:
Collaboration diagram for gum::learning::DirichletPriorFromBN< GUM_SCALAR >:

Public Member Functions

Constructors / Destructors
 DirichletPriorFromBN (const DatabaseTable &learning_db, const BayesNet< GUM_SCALAR > *priorbn)
 default constructor
 DirichletPriorFromBN (const DirichletPriorFromBN &from)
 copy constructor
 DirichletPriorFromBN (DirichletPriorFromBN &&from) noexcept
 move constructor
DirichletPriorFromBNclone () const final
 virtual copy constructor
virtual ~DirichletPriorFromBN ()
 destructor
Operators
DirichletPriorFromBNoperator= (const DirichletPriorFromBN &from)
 copy operator
DirichletPriorFromBNoperator= (DirichletPriorFromBN &&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 virtual sample size)
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 vector defined 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 DatabaseTabledatabase_
 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

Private Member Functions

void _addCountsForJoint_ (Instantiation &Ijoint, const Set< NodeId > &joint, std::vector< double > &counts)

Private Attributes

const BayesNet< GUM_SCALAR > * _prior_bn_

Detailed Description

template<typename GUM_SCALAR>
class gum::learning::DirichletPriorFromBN< GUM_SCALAR >

A dirichlet priori: computes its N'_ijk from a database.

Definition at line 66 of file DirichletPriorFromBN.h.

Constructor & Destructor Documentation

◆ DirichletPriorFromBN() [1/3]

template<typename GUM_SCALAR>
gum::learning::DirichletPriorFromBN< GUM_SCALAR >::DirichletPriorFromBN ( const DatabaseTable & learning_db,
const BayesNet< GUM_SCALAR > * priorbn )

default constructor

Parameters
bnthe prior bayesian network from which computation is performed. This is useful to get access to the random variables
nodeId2priorIda mapping from the ids of the nodes in the graphical model to the corresponding id in the prior BN. An empty nodeId2Columns bijection means that the mapping is an identity.

Referenced by DirichletPriorFromBN(), DirichletPriorFromBN(), ~DirichletPriorFromBN(), clone(), operator=(), and operator=().

Here is the caller graph for this function:

◆ DirichletPriorFromBN() [2/3]

template<typename GUM_SCALAR>
gum::learning::DirichletPriorFromBN< GUM_SCALAR >::DirichletPriorFromBN ( const DirichletPriorFromBN< GUM_SCALAR > & from)

copy constructor

References DirichletPriorFromBN().

Here is the call graph for this function:

◆ DirichletPriorFromBN() [3/3]

template<typename GUM_SCALAR>
gum::learning::DirichletPriorFromBN< GUM_SCALAR >::DirichletPriorFromBN ( DirichletPriorFromBN< GUM_SCALAR > && from)
noexcept

move constructor

References DirichletPriorFromBN().

Here is the call graph for this function:

◆ ~DirichletPriorFromBN()

template<typename GUM_SCALAR>
virtual gum::learning::DirichletPriorFromBN< GUM_SCALAR >::~DirichletPriorFromBN ( )
virtual

destructor

References DirichletPriorFromBN().

Here is the call graph for this function:

Member Function Documentation

◆ _addCountsForJoint_()

template<typename GUM_SCALAR>
void gum::learning::DirichletPriorFromBN< GUM_SCALAR >::_addCountsForJoint_ ( Instantiation & Ijoint,
const Set< NodeId > & joint,
std::vector< double > & counts )
private

References _addCountsForJoint_().

Referenced by _addCountsForJoint_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addConditioningPseudoCount()

template<typename GUM_SCALAR>
void gum::learning::DirichletPriorFromBN< GUM_SCALAR >::addConditioningPseudoCount ( const IdCondSet & idset,
std::vector< double > & counts )
finalvirtual

adds the prior to a counting vector defined over the right hand side of the idset

Warning
the method assumes that the size of the vector is exactly the domain size of the joint RHS variables of the idset.

Implements gum::learning::Prior.

References addConditioningPseudoCount().

Referenced by addConditioningPseudoCount().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addJointPseudoCount()

template<typename GUM_SCALAR>
void gum::learning::DirichletPriorFromBN< GUM_SCALAR >::addJointPseudoCount ( const IdCondSet & idset,
std::vector< double > & counts )
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.

Warning
the method assumes that the size of the vector is exactly the domain size of the joint variables set.

Implements gum::learning::Prior.

References addJointPseudoCount().

Referenced by addJointPseudoCount().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clone()

template<typename GUM_SCALAR>
DirichletPriorFromBN * gum::learning::DirichletPriorFromBN< GUM_SCALAR >::clone ( ) const
finalvirtual

virtual copy constructor

Implements gum::learning::Prior.

References DirichletPriorFromBN().

Here is the call graph for this function:

◆ getType()

template<typename GUM_SCALAR>
PriorType gum::learning::DirichletPriorFromBN< GUM_SCALAR >::getType ( ) const
finalvirtual

returns the type of the prior

Implements gum::learning::Prior.

References getType().

Referenced by getType().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isInformative()

template<typename GUM_SCALAR>
bool gum::learning::DirichletPriorFromBN< GUM_SCALAR >::isInformative ( ) const
finalvirtual

indicates whether the prior is tensorly informative

Basically, only the NoPrior is uninformative. However, it may happen that, under some circumstances, a 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

template<typename GUM_SCALAR>
DirichletPriorFromBN & gum::learning::DirichletPriorFromBN< GUM_SCALAR >::operator= ( const DirichletPriorFromBN< GUM_SCALAR > & from)

copy operator

References DirichletPriorFromBN().

Here is the call graph for this function:

◆ operator=() [2/2]

template<typename GUM_SCALAR>
DirichletPriorFromBN & gum::learning::DirichletPriorFromBN< GUM_SCALAR >::operator= ( DirichletPriorFromBN< GUM_SCALAR > && from)

move operator

References DirichletPriorFromBN().

Here is the call graph for this function:

◆ setWeight()

template<typename GUM_SCALAR>
void gum::learning::DirichletPriorFromBN< GUM_SCALAR >::setWeight ( double weight)
finalvirtual

sets the weight of the a prior(kind of virtual sample size)

Reimplemented from gum::learning::Prior.

References setWeight(), and gum::learning::Prior::weight().

Referenced by setWeight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ weight()

double gum::learning::Prior::weight ( ) const
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().

Here is the caller graph for this function:

Member Data Documentation

◆ _prior_bn_

template<typename GUM_SCALAR>
const BayesNet< GUM_SCALAR >* gum::learning::DirichletPriorFromBN< GUM_SCALAR >::_prior_bn_
private

Definition at line 150 of file DirichletPriorFromBN.h.

◆ database_

const DatabaseTable* gum::learning::Prior::database_
protectedinherited

a reference to the database in order to have access to its variables

Definition at line 161 of file prior.h.

◆ nodeId2columns_

Bijection< NodeId, std::size_t > gum::learning::Prior::nodeId2columns_
protectedinherited

a mapping from the NodeIds of the variables to the indices of the columns in the database

Definition at line 165 of file prior.h.

◆ weight_

double gum::learning::Prior::weight_ {1.0}
protectedinherited

the weight of the prior

Definition at line 158 of file prior.h.

158{1.0};

The documentation for this class was generated from the following file: