![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
The class computing n times the corrected mutual information, as used in the 3off2 algorithm. More...
#include <correctedMutualInformation.h>
Public Member Functions | |
Constructors / Destructors | |
CorrectedMutualInformation (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... | |
CorrectedMutualInformation (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... | |
CorrectedMutualInformation (const CorrectedMutualInformation< ALLOC > &from) | |
copy constructor More... | |
CorrectedMutualInformation (const CorrectedMutualInformation< ALLOC > &from, const allocator_type &alloc) | |
copy constructor with a given allocator More... | |
CorrectedMutualInformation (CorrectedMutualInformation< ALLOC > &&from) | |
move constructor More... | |
CorrectedMutualInformation (CorrectedMutualInformation< ALLOC > &&from, const allocator_type &alloc) | |
move constructor with a given allocator More... | |
virtual CorrectedMutualInformation< ALLOC > * | clone () const |
virtual copy constructor More... | |
virtual CorrectedMutualInformation< ALLOC > * | clone (const allocator_type &alloc) const |
virtual copy constructor with a given allocator More... | |
virtual | ~CorrectedMutualInformation () |
destructor More... | |
Operators | |
CorrectedMutualInformation< ALLOC > & | operator= (const CorrectedMutualInformation< ALLOC > &from) |
copy operator More... | |
CorrectedMutualInformation< ALLOC > & | operator= (CorrectedMutualInformation< ALLOC > &&from) |
move operator More... | |
caching functions | |
virtual void | clear () |
clears all the data structures from memory More... | |
virtual void | clearCache () |
clears all the current caches More... | |
virtual void | useCache (bool on_off) |
turn on/off the use of all the caches More... | |
void | useICache (bool on_off) |
turn on/off the use of the ICache (the mutual information cache) More... | |
void | clearICache () |
clears the ICache (the mutual information cache) More... | |
void | useHCache (bool on_off) |
turn on/off the use of the HCache (the cache for the entropies) More... | |
void | clearHCache () |
clears the HCache (the cache for the entropies) More... | |
void | useKCache (bool on_off) |
turn on/off the use of the KCache (the cache for the penalties) More... | |
void | clearKCache () |
clears the KCache (the cache for the penalties) More... | |
void | useCnrCache (bool on_off) |
turn on/off the use of the CnrCache (the cache for the Cnr formula) More... | |
void | clearCnrCache () |
clears the CnrCache (the cache for the Cnr formula) More... | |
score functions | |
double | score (NodeId var1, NodeId var2) |
returns the 2-point mutual information corresponding to a given nodeset More... | |
double | score (NodeId var1, NodeId var2, const std::vector< NodeId, ALLOC< NodeId > > &conditioning_ids) |
returns the 2-point mutual information corresponding to a given nodeset More... | |
double | score (NodeId var1, NodeId var2, NodeId var3) |
returns the 3-point mutual information corresponding to a given nodeset More... | |
double | score (NodeId var1, NodeId var2, NodeId var3, const std::vector< NodeId, ALLOC< NodeId > > &conditioning_ids) |
returns the 3-point mutual information corresponding to a given nodeset More... | |
Accessors / Modifiers | |
void | useMDL () |
use the MDL penalty function More... | |
void | useNML () |
use the kNML penalty function More... | |
void | useNoCorr () |
use no correction/penalty function More... | |
virtual void | setMaxNbThreads (std::size_t nb) const |
changes the max number of threads used to parse the database More... | |
virtual std::size_t | nbThreads () const |
returns the number of threads used to parse the database More... | |
virtual void | setMinNbRowsPerThread (const std::size_t nb) const |
changes the number min of rows a thread should process in a multithreading context More... | |
virtual std::size_t | minNbRowsPerThread () const |
returns the minimum of rows that each thread should process More... | |
template<template< typename > class XALLOC> | |
void | setRanges (const std::vector< std::pair< std::size_t, std::size_t >, XALLOC< std::pair< std::size_t, std::size_t > > > &new_ranges) |
sets new ranges to perform the countings used by the mutual information More... | |
void | clearRanges () |
reset the ranges to the one range corresponding to the whole database More... | |
const std::vector< std::pair< std::size_t, std::size_t >, ALLOC< std::pair< std::size_t, std::size_t > > > & | ranges () const |
returns the current ranges More... | |
allocator_type | getAllocator () const |
returns the allocator used by the score More... | |
Public Types | |
enum | KModeTypes { KModeTypes::MDL, KModeTypes::NML, KModeTypes::NoCorr } |
the description type for the complexity correction More... | |
using | allocator_type = ALLOC< NodeId > |
type for the allocators passed in arguments of methods More... | |
The class computing n times the corrected mutual information, as used in the 3off2 algorithm.
This class handles the computations and storage of the mutual information values used in 3off2 and potential corrections.
Definition at line 56 of file correctedMutualInformation.h.
using gum::learning::CorrectedMutualInformation< ALLOC >::allocator_type = ALLOC< NodeId > |
type for the allocators passed in arguments of methods
Definition at line 59 of file correctedMutualInformation.h.
|
strong |
the description type for the complexity correction
Enumerator | |
---|---|
MDL | |
NML | |
NoCorr |
Definition at line 308 of file correctedMutualInformation.h.
gum::learning::CorrectedMutualInformation< ALLOC >::CorrectedMutualInformation | ( | 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::CorrectedMutualInformation< ALLOC >::CorrectedMutualInformation | ( | 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::CorrectedMutualInformation< ALLOC >::CorrectedMutualInformation | ( | const CorrectedMutualInformation< ALLOC > & | from | ) |
copy constructor
gum::learning::CorrectedMutualInformation< ALLOC >::CorrectedMutualInformation | ( | const CorrectedMutualInformation< ALLOC > & | from, |
const allocator_type & | alloc | ||
) |
copy constructor with a given allocator
gum::learning::CorrectedMutualInformation< ALLOC >::CorrectedMutualInformation | ( | CorrectedMutualInformation< ALLOC > && | from | ) |
move constructor
gum::learning::CorrectedMutualInformation< ALLOC >::CorrectedMutualInformation | ( | CorrectedMutualInformation< ALLOC > && | from, |
const allocator_type & | alloc | ||
) |
move constructor with a given allocator
|
virtual |
destructor
|
virtual |
clears all the data structures from memory
|
virtual |
clears all the current caches
There are 4 caches in the CorrectedMutualInformation class:
informations used by 3off2
of the entropies used in the mutual information formula
of the Cnr formula used by the kNML penalty
void gum::learning::CorrectedMutualInformation< ALLOC >::clearCnrCache | ( | ) |
clears the CnrCache (the cache for the Cnr formula)
void gum::learning::CorrectedMutualInformation< ALLOC >::clearHCache | ( | ) |
clears the HCache (the cache for the entropies)
void gum::learning::CorrectedMutualInformation< ALLOC >::clearICache | ( | ) |
clears the ICache (the mutual information cache)
void gum::learning::CorrectedMutualInformation< ALLOC >::clearKCache | ( | ) |
clears the KCache (the cache for the penalties)
void gum::learning::CorrectedMutualInformation< ALLOC >::clearRanges | ( | ) |
reset the ranges to the one range corresponding to the whole database
|
virtual |
virtual copy constructor
|
virtual |
virtual copy constructor with a given allocator
allocator_type gum::learning::CorrectedMutualInformation< ALLOC >::getAllocator | ( | ) | const |
returns the allocator used by the score
|
virtual |
returns the minimum of rows that each thread should process
|
virtual |
returns the number of threads used to parse the database
CorrectedMutualInformation< ALLOC >& gum::learning::CorrectedMutualInformation< ALLOC >::operator= | ( | const CorrectedMutualInformation< ALLOC > & | from | ) |
copy operator
CorrectedMutualInformation< ALLOC >& gum::learning::CorrectedMutualInformation< ALLOC >::operator= | ( | CorrectedMutualInformation< ALLOC > && | from | ) |
move operator
const std::vector< std::pair< std::size_t, std::size_t >, ALLOC< std::pair< std::size_t, std::size_t > > >& gum::learning::CorrectedMutualInformation< ALLOC >::ranges | ( | ) | const |
returns the current ranges
double gum::learning::CorrectedMutualInformation< ALLOC >::score | ( | NodeId | var1, |
NodeId | var2 | ||
) |
returns the 2-point mutual information corresponding to a given nodeset
double gum::learning::CorrectedMutualInformation< ALLOC >::score | ( | NodeId | var1, |
NodeId | var2, | ||
const std::vector< NodeId, ALLOC< NodeId > > & | conditioning_ids | ||
) |
returns the 2-point mutual information corresponding to a given nodeset
double gum::learning::CorrectedMutualInformation< ALLOC >::score | ( | NodeId | var1, |
NodeId | var2, | ||
NodeId | var3 | ||
) |
returns the 3-point mutual information corresponding to a given nodeset
double gum::learning::CorrectedMutualInformation< ALLOC >::score | ( | NodeId | var1, |
NodeId | var2, | ||
NodeId | var3, | ||
const std::vector< NodeId, ALLOC< NodeId > > & | conditioning_ids | ||
) |
returns the 3-point mutual information corresponding to a given nodeset
|
virtual |
changes the max number of threads used to parse the database
|
virtual |
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.
void gum::learning::CorrectedMutualInformation< ALLOC >::setRanges | ( | const std::vector< std::pair< std::size_t, std::size_t >, XALLOC< std::pair< std::size_t, std::size_t > > > & | new_ranges | ) |
sets new ranges to perform the countings used by the mutual information
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 all the caches
There are 4 caches in the CorrectedMutualInformation class:
informations used by 3off2
of the entropies used in the mutual information formula
of the Cnr formula used by the kNML penalty
void gum::learning::CorrectedMutualInformation< ALLOC >::useCnrCache | ( | bool | on_off | ) |
turn on/off the use of the CnrCache (the cache for the Cnr formula)
void gum::learning::CorrectedMutualInformation< ALLOC >::useHCache | ( | bool | on_off | ) |
turn on/off the use of the HCache (the cache for the entropies)
void gum::learning::CorrectedMutualInformation< ALLOC >::useICache | ( | bool | on_off | ) |
turn on/off the use of the ICache (the mutual information cache)
void gum::learning::CorrectedMutualInformation< ALLOC >::useKCache | ( | bool | on_off | ) |
turn on/off the use of the KCache (the cache for the penalties)
void gum::learning::CorrectedMutualInformation< ALLOC >::useMDL | ( | ) |
use the MDL penalty function
void gum::learning::CorrectedMutualInformation< ALLOC >::useNML | ( | ) |
use the kNML penalty function
void gum::learning::CorrectedMutualInformation< ALLOC >::useNoCorr | ( | ) |
use no correction/penalty function