![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
the class for computing the NML penalty used by 3off2 More...
#include <kNML.h>
Public Member Functions | |
Constructors / Destructors | |
KNML (const DBRowGeneratorParser< ALLOC > &parser, const Apriori< ALLOC > &apriori, const std::vector< std::pair< std::size_t, std::size_t >, ALLOC< std::pair< std::size_t, std::size_t > > > &ranges, 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... | |
KNML (const DBRowGeneratorParser< ALLOC > &parser, const Apriori< ALLOC > &apriori, 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... | |
KNML (const KNML< ALLOC > &from) | |
copy constructor More... | |
KNML (const KNML< ALLOC > &from, const allocator_type &alloc) | |
copy constructor with a given allocator More... | |
KNML (KNML< ALLOC > &&from) | |
move constructor More... | |
KNML (KNML< ALLOC > &&from, const allocator_type &alloc) | |
move constructor with a given allocator More... | |
virtual KNML< ALLOC > * | clone () const |
virtual copy constructor More... | |
virtual KNML< ALLOC > * | clone (const allocator_type &alloc) const |
virtual copy constructor with a given allocator More... | |
virtual | ~KNML () |
destructor More... | |
Operators | |
KNML< ALLOC > & | operator= (const KNML< ALLOC > &from) |
copy operator More... | |
KNML< ALLOC > & | operator= (KNML< ALLOC > &&from) |
move operator More... | |
Accessors / Modifiers | |
virtual void | clear () |
clears all the data structures from memory, including the C_n^r cache More... | |
virtual void | clearCache () |
clears the current C_n^r cache More... | |
virtual void | useCache (const bool on_off) |
turn on/off the use of the C_n^r cache More... | |
Public Types | |
using | allocator_type = ALLOC< NodeId > |
type for the allocators passed in arguments of methods More... | |
Protected Member Functions | |
virtual double | score_ (const IdCondSet< ALLOC > &idset) final |
returns the score for a given IdCondSet More... | |
the class for computing the NML penalty used by 3off2
using gum::learning::KNML< ALLOC >::allocator_type = ALLOC< NodeId > |
gum::learning::KNML< ALLOC >::KNML | ( | const DBRowGeneratorParser< ALLOC > & | parser, |
const Apriori< ALLOC > & | apriori, | ||
const std::vector< std::pair< std::size_t, std::size_t >, ALLOC< std::pair< std::size_t, std::size_t > > > & | ranges, | ||
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
parser | the parser used to parse the database |
apriori | An apriori that we add to the computation of the score (this should come from expert knowledge): this consists in adding numbers to countings in the contingency tables |
ranges | a set of pairs {(X1,Y1),...,(Xn,Yn)} of database's rows indices. The countings are then performed only on the union of the rows [Xi,Yi), i in {1,...,n}. This is useful, e.g, when performing cross validation tasks, in which part of the database should be ignored. An empty set of ranges is equivalent to an interval [X,Y) ranging over the whole database. |
nodeId2Columns | a mapping from the ids of the nodes in the graphical model to the corresponding column in the DatabaseTable parsed by the parser. 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 Score. |
gum::learning::KNML< ALLOC >::KNML | ( | const DBRowGeneratorParser< ALLOC > & | parser, |
const Apriori< ALLOC > & | apriori, | ||
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
parser | the parser used to parse the database |
apriori | An apriori that we add to the computation of the score (this should come from expert knowledge): this consists in adding numbers to countings in the contingency tables |
nodeId2Columns | a mapping from the ids of the nodes in the graphical model to the corresponding column in the DatabaseTable parsed by the parser. 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 Score. |
gum::learning::KNML< ALLOC >::KNML | ( | const KNML< ALLOC > & | from | ) |
copy constructor
gum::learning::KNML< ALLOC >::KNML | ( | const KNML< ALLOC > & | from, |
const allocator_type & | alloc | ||
) |
copy constructor with a given allocator
gum::learning::KNML< ALLOC >::KNML | ( | KNML< ALLOC > && | from | ) |
move constructor
gum::learning::KNML< ALLOC >::KNML | ( | KNML< ALLOC > && | from, |
const allocator_type & | alloc | ||
) |
move constructor with a given allocator
|
virtual |
destructor
|
virtual |
clears all the data structures from memory, including the C_n^r cache
Reimplemented from gum::learning::IndependenceTest< ALLOC >.
|
virtual |
clears the current C_n^r cache
Reimplemented from gum::learning::IndependenceTest< ALLOC >.
|
inherited |
reset the ranges to the one range corresponding to the whole database
|
virtual |
virtual copy constructor
Implements gum::learning::IndependenceTest< ALLOC >.
|
virtual |
virtual copy constructor with a given allocator
Implements gum::learning::IndependenceTest< ALLOC >.
|
inherited |
return the database used by the score
|
inherited |
returns the allocator used by the score
|
protectedinherited |
returns a counting vector where variables are marginalized from N_xyz
node_2_marginalize | indicates which node(s) shall be marginalized:
|
X_size | the domain size of variable X |
Y_size | the domain size of variable Y |
Z_size | the domain size of the set of conditioning variables Z |
N_xyz | a counting vector of dimension X * Y * Z (in this order) |
|
virtualinherited |
returns the minimum of rows that each thread should process
|
virtualinherited |
returns the number of threads used to parse the database
|
inherited |
return the mapping between the columns of the database and the node ids
KNML< ALLOC >& gum::learning::KNML< ALLOC >::operator= | ( | const KNML< ALLOC > & | from | ) |
copy operator
KNML< ALLOC >& gum::learning::KNML< ALLOC >::operator= | ( | KNML< ALLOC > && | from | ) |
move operator
|
inherited |
returns the current ranges
|
inherited |
returns the score of a pair of nodes
|
inherited |
returns the score of a pair of nodes given some other nodes
var1 | the first variable on the left side of the conditioning bar |
var2 | the second variable on the left side of the conditioning bar |
rhs_ids | the set of variables on the right side of the conditioning bar |
|
finalprotectedvirtual |
returns the score for a given IdCondSet
OperationNotAllowed | is raised if the score does not support calling method score such an idset (due to too many/too few variables in the left hand side or the right hand side of the idset). |
Implements gum::learning::IndependenceTest< ALLOC >.
|
virtualinherited |
changes the max number of threads used to parse the database
|
virtualinherited |
changes the number min of rows a thread should process in a multithreading context
When computing score, several threads are used by record counters to perform countings on the rows of the database, the MinNbRowsPerThread method indicates how many rows each thread should at least process. This is used to compute the number of threads actually run. This number is equal to the min between the max number of threads allowed and the number of records in the database divided by nb.
|
inherited |
sets new ranges to perform the countings used by the independence test
ranges | a set of pairs {(X1,Y1),...,(Xn,Yn)} of database's rows indices. The countings are then performed only on the union of the rows [Xi,Yi), i in {1,...,n}. This is useful, e.g, when performing cross validation tasks, in which part of the database should be ignored. An empty set of ranges is equivalent to an interval [X,Y) ranging over the whole database. |
|
virtual |
turn on/off the use of the C_n^r cache
Reimplemented from gum::learning::IndependenceTest< ALLOC >.
|
protectedinherited |
the expert knowledge a priori we add to the contingency tables
Definition at line 215 of file independenceTest.h.
|
protectedinherited |
the scoring cache
Definition at line 221 of file independenceTest.h.
|
protectedinherited |
the record counter used for the countings over discrete variables
Definition at line 218 of file independenceTest.h.
|
protectedinherited |
an empty vector
Definition at line 227 of file independenceTest.h.
|
protectedinherited |
1 / log(2)
Definition at line 212 of file independenceTest.h.
|
protectedinherited |
a Boolean indicating whether we wish to use the cache
Definition at line 224 of file independenceTest.h.