![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
The class for giving access to pseudo count : count in the database + prior. More...
#include <pseudoCount.h>
Public Member Functions | |
Constructors / Destructors | |
PseudoCount (const DBRowGeneratorParser< ALLOC > &parser, const Apriori< ALLOC > &external_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... | |
PseudoCount (const DBRowGeneratorParser< ALLOC > &parser, const Apriori< ALLOC > &external_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... | |
virtual | ~PseudoCount () |
destructor More... | |
PseudoCount (const PseudoCount< ALLOC > &from) | |
copy constructor More... | |
PseudoCount (const PseudoCount< ALLOC > &from, const allocator_type &alloc) | |
copy constructor with a given allocator More... | |
PseudoCount (PseudoCount< ALLOC > &&from) | |
move constructor More... | |
PseudoCount (PseudoCount< ALLOC > &&from, const allocator_type &alloc) | |
move constructor with a given allocator More... | |
PseudoCount< ALLOC > & | operator= (const PseudoCount< ALLOC > &from) |
copy operator More... | |
PseudoCount< ALLOC > & | operator= (PseudoCount< ALLOC > &&from) |
move operator More... | |
Accessors / Modifiers | |
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 independence test 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... | |
std::vector< double, ALLOC< double > > | get (const std::vector< NodeId, ALLOC< NodeId > > &ids) |
returns the pseudo-count of a pair of nodes given some other nodes More... | |
virtual void | clear () |
clears all the data structures from memory, including the cache More... | |
const Bijection< NodeId, std::size_t, ALLOC< std::size_t > > & | nodeId2Columns () const |
return the mapping between the columns of the database and the node ids More... | |
const DatabaseTable< ALLOC > & | database () const |
return the database used by the pseudo-count More... | |
allocator_type | getAllocator () const |
returns the allocator used by the pseudo-count More... | |
Public Types | |
using | allocator_type = ALLOC< NodeId > |
type for the allocators passed in arguments of methods More... | |
Protected Attributes | |
Apriori< ALLOC > * | apriori_ {nullptr} |
the expert knowledge a priori we add to the contingency tables More... | |
RecordCounter< ALLOC > | counter_ |
the record counter used for the countings over discrete variables More... | |
const std::vector< NodeId, ALLOC< NodeId > > | empty_ids_ |
an empty vector More... | |
The class for giving access to pseudo count : count in the database + prior.
Definition at line 52 of file pseudoCount.h.
using gum::learning::PseudoCount< ALLOC >::allocator_type = ALLOC< NodeId > |
type for the allocators passed in arguments of methods
Definition at line 55 of file pseudoCount.h.
gum::learning::PseudoCount< ALLOC >::PseudoCount | ( | const DBRowGeneratorParser< ALLOC > & | parser, |
const Apriori< ALLOC > & | external_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 |
external_apriori | An apriori that we add to the computation of the pseudo-count (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 PseudoCount. |
gum::learning::PseudoCount< ALLOC >::PseudoCount | ( | const DBRowGeneratorParser< ALLOC > & | parser, |
const Apriori< ALLOC > & | external_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 |
external_apriori | An apriori that we add to the computation of the pseudo-count (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 PseudoCount. |
|
virtual |
destructor
gum::learning::PseudoCount< ALLOC >::PseudoCount | ( | const PseudoCount< ALLOC > & | from | ) |
copy constructor
gum::learning::PseudoCount< ALLOC >::PseudoCount | ( | const PseudoCount< ALLOC > & | from, |
const allocator_type & | alloc | ||
) |
copy constructor with a given allocator
gum::learning::PseudoCount< ALLOC >::PseudoCount | ( | PseudoCount< ALLOC > && | from | ) |
move constructor
gum::learning::PseudoCount< ALLOC >::PseudoCount | ( | PseudoCount< ALLOC > && | from, |
const allocator_type & | alloc | ||
) |
move constructor with a given allocator
|
virtual |
clears all the data structures from memory, including the cache
void gum::learning::PseudoCount< ALLOC >::clearRanges | ( | ) |
reset the ranges to the one range corresponding to the whole database
const DatabaseTable< ALLOC >& gum::learning::PseudoCount< ALLOC >::database | ( | ) | const |
return the database used by the pseudo-count
std::vector< double, ALLOC< double > > gum::learning::PseudoCount< ALLOC >::get | ( | const std::vector< NodeId, ALLOC< NodeId > > & | ids | ) |
returns the pseudo-count 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 |
allocator_type gum::learning::PseudoCount< ALLOC >::getAllocator | ( | ) | const |
returns the allocator used by the pseudo-count
|
virtual |
returns the minimum of rows that each thread should process
|
virtual |
returns the number of threads used to parse the database
const Bijection< NodeId, std::size_t, ALLOC< std::size_t > >& gum::learning::PseudoCount< ALLOC >::nodeId2Columns | ( | ) | const |
return the mapping between the columns of the database and the node ids
PseudoCount< ALLOC >& gum::learning::PseudoCount< ALLOC >::operator= | ( | const PseudoCount< ALLOC > & | from | ) |
copy operator
PseudoCount< ALLOC >& gum::learning::PseudoCount< ALLOC >::operator= | ( | PseudoCount< 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::PseudoCount< ALLOC >::ranges | ( | ) | const |
returns the current ranges
|
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 pseudo-count, 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::PseudoCount< 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 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. |
|
protected |
the expert knowledge a priori we add to the contingency tables
Definition at line 213 of file pseudoCount.h.
|
protected |
the record counter used for the countings over discrete variables
Definition at line 216 of file pseudoCount.h.
|
protected |
an empty vector
Definition at line 219 of file pseudoCount.h.