aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::learning::Prior Class Referenceabstract

the base class for all a priori More...

#include <agrum/BN/learning/priors/prior.h>

Inheritance diagram for gum::learning::Prior:
Collaboration diagram for gum::learning::Prior:

Public Member Functions

Constructors / Destructors
 Prior (const DatabaseTable &database, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
 default constructor
virtual Priorclone () const =0
 virtual copy constructor
virtual ~Prior ()
 destructor
Accessors / Modifiers
virtual void setWeight (double weight)
 sets the weight of the a prior(kind of effective sample size)
double weight () const
 returns the weight assigned to the prior
virtual PriorType getType () const =0
 returns the type of the prior
virtual bool isInformative () const =0
 indicates whether the prior is tensorly informative
virtual void addJointPseudoCount (const IdCondSet &idset, std::vector< double > &counts)=0
 adds the prior to a counting vector corresponding to the idset
virtual void addConditioningPseudoCount (const IdCondSet &idset, std::vector< double > &counts)=0
 adds the prior to a counting vector defined over the right hand side of the idset

Protected Member Functions

 Prior (const Prior &from)
 copy constructor
 Prior (Prior &&from)
 move constructor
Prioroperator= (const Prior &from)
 copy operator
Prioroperator= (Prior &&from)
 move operator

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

Detailed Description

the base class for all a priori

Definition at line 83 of file prior.h.

Constructor & Destructor Documentation

◆ Prior() [1/3]

gum::learning::Prior::Prior ( const DatabaseTable & database,
const Bijection< NodeId, std::size_t > & nodeId2columns = BijectionNodeId, std::size_t >() )
explicit

default constructor

Parameters
databasethe database from which learning is performed. This is useful to get access to the random variables
nodeId2Columnsa mapping from the ids of the nodes in the graphical model to the corresponding column in the DatabaseTable. 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.

Referenced by Prior(), Prior(), clone(), operator=(), and operator=().

Here is the caller graph for this function:

◆ ~Prior()

virtual gum::learning::Prior::~Prior ( )
virtual

destructor

◆ Prior() [2/3]

gum::learning::Prior::Prior ( const Prior & from)
protected

copy constructor

References Prior().

Here is the call graph for this function:

◆ Prior() [3/3]

gum::learning::Prior::Prior ( Prior && from)
protected

move constructor

References Prior().

Here is the call graph for this function:

Member Function Documentation

◆ addConditioningPseudoCount()

virtual void gum::learning::Prior::addConditioningPseudoCount ( const IdCondSet & idset,
std::vector< double > & counts )
pure virtual

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.

Implemented in gum::learning::BDeuPrior, gum::learning::DirichletPriorFromBN< GUM_SCALAR >, gum::learning::DirichletPriorFromDatabase, gum::learning::NoPrior, and gum::learning::SmoothingPrior.

◆ addJointPseudoCount()

virtual void gum::learning::Prior::addJointPseudoCount ( const IdCondSet & idset,
std::vector< double > & counts )
pure virtual

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.

Implemented in gum::learning::BDeuPrior, gum::learning::DirichletPriorFromBN< GUM_SCALAR >, gum::learning::DirichletPriorFromDatabase, gum::learning::NoPrior, and gum::learning::SmoothingPrior.

◆ clone()

virtual Prior * gum::learning::Prior::clone ( ) const
pure virtual

virtual copy constructor

Implemented in gum::learning::BDeuPrior, gum::learning::DirichletPriorFromBN< GUM_SCALAR >, gum::learning::DirichletPriorFromDatabase, gum::learning::K2Prior, gum::learning::NoPrior, and gum::learning::SmoothingPrior.

References Prior().

Here is the call graph for this function:

◆ getType()

virtual PriorType gum::learning::Prior::getType ( ) const
pure virtual

◆ isInformative()

virtual bool gum::learning::Prior::isInformative ( ) const
pure virtual

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.

Implemented in gum::learning::BDeuPrior, gum::learning::DirichletPriorFromBN< GUM_SCALAR >, gum::learning::DirichletPriorFromDatabase, gum::learning::NoPrior, and gum::learning::SmoothingPrior.

◆ operator=() [1/2]

Prior & gum::learning::Prior::operator= ( const Prior & from)
protected

copy operator

References Prior().

Here is the call graph for this function:

◆ operator=() [2/2]

Prior & gum::learning::Prior::operator= ( Prior && from)
protected

move operator

References Prior().

Here is the call graph for this function:

◆ setWeight()

virtual void gum::learning::Prior::setWeight ( double weight)
virtual

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

Reimplemented in gum::learning::BDeuPrior, gum::learning::DirichletPriorFromBN< GUM_SCALAR >, gum::learning::DirichletPriorFromDatabase, gum::learning::K2Prior, and gum::learning::NoPrior.

References weight().

Here is the call graph for this function:

◆ weight()

double gum::learning::Prior::weight ( ) const

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

◆ database_

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

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_
protected

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}
protected

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: