![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
the internal apriori for the BDeu score (N' / (r_i * q_i)BDeu is a BD score with a N'/(r_i * q_i) apriori, 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. More...
#include <agrum/tools/database/aprioriBDeu.h>
Public Member Functions | |
Constructors / Destructors | |
AprioriBDeu (const DatabaseTable< ALLOC > &database, const Bijection< NodeId, std::size_t, ALLOC< std::size_t > > &nodeId2columns=Bijection< NodeId, std::size_t, ALLOC< std::size_t > >(), const allocator_type &alloc=allocator_type()) | |
default constructor More... | |
AprioriBDeu (const AprioriBDeu< ALLOC > &from) | |
copy constructor More... | |
AprioriBDeu (const AprioriBDeu< ALLOC > &from, const allocator_type &alloc) | |
copy constructor with a given allocator More... | |
AprioriBDeu (AprioriBDeu< ALLOC > &&from) | |
move constructor More... | |
AprioriBDeu (AprioriBDeu< ALLOC > &&from, const allocator_type &alloc) | |
move constructor with a given allocator More... | |
virtual AprioriBDeu< ALLOC > * | clone () const |
virtual copy constructor More... | |
virtual AprioriBDeu< ALLOC > * | clone (const allocator_type &alloc) const |
virtual copy constructor with a given allocator More... | |
virtual | ~AprioriBDeu () |
destructor More... | |
Operators | |
AprioriBDeu< ALLOC > & | operator= (const AprioriBDeu< ALLOC > &from) |
copy operator More... | |
AprioriBDeu< ALLOC > & | operator= (AprioriBDeu< ALLOC > &&from) |
move operator More... | |
Accessors / Modifiers | |
virtual void | setWeight (const double weight) final |
sets the effective sample size N' (alias of setEffectiveSampleSize ()) More... | |
void | setEffectiveSampleSize (const double weight) |
sets the effective sample size N' More... | |
virtual bool | isOfType (const std::string &type) final |
indicates whether an apriori is of a certain type More... | |
virtual const std::string & | getType () const final |
returns the type of the apriori More... | |
virtual bool | isInformative () const final |
indicates whether the apriori is potentially informative More... | |
virtual void | addAllApriori (const IdCondSet< ALLOC > &idset, std::vector< double, ALLOC< double > > &counts) final |
adds the apriori to a counting vector corresponding to the idset More... | |
virtual void | addConditioningApriori (const IdCondSet< ALLOC > &idset, std::vector< double, ALLOC< double > > &counts) final |
adds the apriori to a counting vectordefined over the right hand side of the idset More... | |
Accessors / Modifiers | |
double | weight () const |
returns the weight assigned to the apriori More... | |
allocator_type | getAllocator () const |
returns the allocator used by the internal apriori More... | |
Public Types | |
using | type = AprioriBDeuType |
the type of the a priori More... | |
using | allocator_type = ALLOC< NodeId > |
type for the allocators passed in arguments of methods More... | |
Protected Attributes | |
double | weight_ {1.0} |
the weight of the apriori More... | |
const DatabaseTable< ALLOC > * | database_ |
a reference to the database in order to have access to its variables More... | |
Bijection< NodeId, std::size_t, ALLOC< std::size_t > > | nodeId2columns_ |
a mapping from the NodeIds of the variables to the indices of the columns in the database More... | |
the internal apriori for the BDeu score (N' / (r_i * q_i)
BDeu is a BD score with a N'/(r_i * q_i) apriori, 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 aprioris are taken into account during structure learning and parameter learning.
Definition at line 53 of file aprioriBDeu.h.
using gum::learning::AprioriBDeu< ALLOC >::allocator_type = ALLOC< NodeId > |
type for the allocators passed in arguments of methods
Definition at line 59 of file aprioriBDeu.h.
using gum::learning::AprioriBDeu< ALLOC >::type = AprioriBDeuType |
the type of the a priori
Definition at line 56 of file aprioriBDeu.h.
gum::learning::AprioriBDeu< ALLOC >::AprioriBDeu | ( | const DatabaseTable< ALLOC > & | database, |
const Bijection< NodeId, std::size_t, ALLOC< std::size_t > > & | nodeId2columns = Bijection< NodeId, std::size_t, ALLOC< std::size_t > >() , |
||
const allocator_type & | alloc = allocator_type() |
||
) |
default constructor
database | the database from which learning is performed. This is useful to get access to the random variables |
nodeId2Columns | a 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. |
alloc | the allocator used to allocate the structures within the RecordCounter. |
gum::learning::AprioriBDeu< ALLOC >::AprioriBDeu | ( | const AprioriBDeu< ALLOC > & | from | ) |
copy constructor
gum::learning::AprioriBDeu< ALLOC >::AprioriBDeu | ( | const AprioriBDeu< ALLOC > & | from, |
const allocator_type & | alloc | ||
) |
copy constructor with a given allocator
gum::learning::AprioriBDeu< ALLOC >::AprioriBDeu | ( | AprioriBDeu< ALLOC > && | from | ) |
move constructor
gum::learning::AprioriBDeu< ALLOC >::AprioriBDeu | ( | AprioriBDeu< ALLOC > && | from, |
const allocator_type & | alloc | ||
) |
move constructor with a given allocator
|
virtual |
destructor
|
finalvirtual |
adds the apriori to a counting vector corresponding to the idset
adds the apriori 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::Apriori< ALLOC >.
|
finalvirtual |
adds the apriori to a counting vectordefined over the right hand side of the idset
Implements gum::learning::Apriori< ALLOC >.
|
virtual |
virtual copy constructor
Implements gum::learning::Apriori< ALLOC >.
|
virtual |
virtual copy constructor with a given allocator
Implements gum::learning::Apriori< ALLOC >.
|
inherited |
returns the allocator used by the internal apriori
|
finalvirtual |
returns the type of the apriori
Implements gum::learning::Apriori< ALLOC >.
|
finalvirtual |
indicates whether the apriori is potentially informative
Basically, only the NoApriori is uninformative. However, it may happen that, under some circonstances, an apriori, which is usually not equal to the NoApriori, becomes equal to it (e.g., when the weight is equal to zero). In this case, if the apriori 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 apriori in their computations.
Implements gum::learning::Apriori< ALLOC >.
|
finalvirtual |
indicates whether an apriori is of a certain type
Implements gum::learning::Apriori< ALLOC >.
AprioriBDeu< ALLOC >& gum::learning::AprioriBDeu< ALLOC >::operator= | ( | const AprioriBDeu< ALLOC > & | from | ) |
copy operator
AprioriBDeu< ALLOC >& gum::learning::AprioriBDeu< ALLOC >::operator= | ( | AprioriBDeu< ALLOC > && | from | ) |
move operator
void gum::learning::AprioriBDeu< ALLOC >::setEffectiveSampleSize | ( | const double | weight | ) |
sets the effective sample size N'
|
finalvirtual |
sets the effective sample size N' (alias of setEffectiveSampleSize ())
Reimplemented from gum::learning::Apriori< ALLOC >.
|
inherited |
returns the weight assigned to the apriori
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |