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

the internal prior for the BDeu score (N' / (r_i * q_i) More...

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

Inheritance diagram for gum::learning::BDeuPrior:
Collaboration diagram for gum::learning::BDeuPrior:

Public Member Functions

Constructors / Destructors
 BDeuPrior (const DatabaseTable &database, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
 default constructor
 BDeuPrior (const BDeuPrior &from)
 copy constructor
 BDeuPrior (BDeuPrior &&from) noexcept
 move constructor
BDeuPriorclone () const override
 virtual copy constructor
virtual ~BDeuPrior ()
 destructor
Operators
BDeuPrioroperator= (const BDeuPrior &from)
 copy operator
BDeuPrioroperator= (BDeuPrior &&from) noexcept
 move operator
Accessors / Modifiers
void setWeight (double weight) final
 sets the effective sample size N' (alias of setEffectiveSampleSize ())
void setEffectiveSampleSize (double weight)
 sets the effective sample size N'
PriorType getType () const final
 returns the type of the prior
bool isInformative () const final
 indicates whether the prior is tensorly informative
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

Detailed Description

the internal prior for the BDeu score (N' / (r_i * q_i)

BDeu is a BD score with a N'/(r_i * q_i) prior, where N' is an effective sample size and r_i is the domain size of the target variable and q_i is the domain size of the Cartesian product of its parents.

It is important to note that, to be meaningful a structure + parameter learning requires that the same priors are taken into account during structure learning and parameter learning.

Definition at line 71 of file bdeuPrior.h.

Constructor & Destructor Documentation

◆ BDeuPrior() [1/3]

gum::learning::BDeuPrior::BDeuPrior ( 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 BDeuPrior(), BDeuPrior(), clone(), operator=(), and operator=().

Here is the caller graph for this function:

◆ BDeuPrior() [2/3]

gum::learning::BDeuPrior::BDeuPrior ( const BDeuPrior & from)

copy constructor

References BDeuPrior().

Here is the call graph for this function:

◆ BDeuPrior() [3/3]

gum::learning::BDeuPrior::BDeuPrior ( BDeuPrior && from)
noexcept

move constructor

References BDeuPrior().

Here is the call graph for this function:

◆ ~BDeuPrior()

virtual gum::learning::BDeuPrior::~BDeuPrior ( )
virtual

destructor

Member Function Documentation

◆ addConditioningPseudoCount()

void gum::learning::BDeuPrior::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()

void gum::learning::BDeuPrior::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()

BDeuPrior * gum::learning::BDeuPrior::clone ( ) const
overridevirtual

virtual copy constructor

Implements gum::learning::Prior.

References BDeuPrior().

Here is the call graph for this function:

◆ getType()

PriorType gum::learning::BDeuPrior::getType ( ) const
finalvirtual

returns the type of the prior

Implements gum::learning::Prior.

◆ isInformative()

bool gum::learning::BDeuPrior::isInformative ( ) const
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().

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

◆ operator=() [1/2]

BDeuPrior & gum::learning::BDeuPrior::operator= ( BDeuPrior && from)
noexcept

move operator

References BDeuPrior().

Here is the call graph for this function:

◆ operator=() [2/2]

BDeuPrior & gum::learning::BDeuPrior::operator= ( const BDeuPrior & from)

copy operator

References BDeuPrior().

Here is the call graph for this function:

◆ setEffectiveSampleSize()

void gum::learning::BDeuPrior::setEffectiveSampleSize ( double weight)

sets the effective sample size N'

References gum::learning::Prior::weight().

Here is the call graph for this function:

◆ setWeight()

void gum::learning::BDeuPrior::setWeight ( double weight)
finalvirtual

sets the effective sample size N' (alias of setEffectiveSampleSize ())

Reimplemented from gum::learning::Prior.

References gum::learning::Prior::weight().

Here is the call 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

◆ 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: