27 #ifndef GUM_LEARNING_PSEUDO_COUNT_H 28 #define GUM_LEARNING_PSEUDO_COUNT_H 32 #include <agrum/agrum.h> 33 #include <agrum/tools/core/math/math_utils.h> 34 #include <agrum/tools/core/OMPThreads.h> 36 #include <agrum/tools/stattests/recordCounter.h> 37 #include <agrum/BN/learning/aprioris/apriori.h> 38 #include <agrum/tools/variables/discreteVariable.h> 39 #include <agrum/tools/multidim/potential.h> 51 template <
template <
typename >
class ALLOC =
std::
allocator >
85 PseudoCount(
const DBRowGeneratorParser< ALLOC >& parser,
86 const Apriori< ALLOC >& external_apriori,
87 const std::vector< std::pair< std::size_t, std::size_t >,
88 ALLOC< std::pair< std::size_t, std::size_t > > >& ranges,
111 PseudoCount(
const DBRowGeneratorParser< ALLOC >& parser,
112 const Apriori< ALLOC >& external_apriori,
125 PseudoCount(
const PseudoCount< ALLOC >& from,
const allocator_type& alloc);
131 PseudoCount(PseudoCount< ALLOC >&& from,
const allocator_type& alloc);
173 template <
template <
typename >
class XALLOC >
175 const std::vector< std::pair< std::size_t, std::size_t >,
176 XALLOC< std::pair< std::size_t, std::size_t > > >& new_ranges);
194 virtual void clear();
225 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 226 extern template class gum::learning::PseudoCount<>;
231 #include <agrum/tools/stattests/pseudoCount_tpl.h> allocator_type getAllocator() const
returns the allocator used by the pseudo-count
void clearRanges()
reset the ranges to the one range corresponding to the whole database
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
PseudoCount(const PseudoCount< ALLOC > &from)
copy constructor
INLINE void emplace(Args &&... args)
RecordCounter< ALLOC > counter_
the record counter used for the countings over discrete variables
PseudoCount< ALLOC > & operator=(PseudoCount< ALLOC > &&from)
move operator
virtual void setMaxNbThreads(std::size_t nb) const
changes the max number of threads used to parse the database
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
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
virtual void clear()
clears all the data structures from memory, including the cache
PseudoCount(PseudoCount< ALLOC > &&from, const allocator_type &alloc)
move constructor with a given allocator
Apriori< ALLOC > * apriori_
the expert knowledge a priori we add to the contingency tables
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
const DatabaseTable< ALLOC > & database() const
return the database used by the pseudo-count
virtual void setMinNbRowsPerThread(const std::size_t nb) const
changes the number min of rows a thread should process in a multithreading context ...
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
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
PseudoCount(const PseudoCount< ALLOC > &from, const allocator_type &alloc)
copy constructor with a given allocator
PseudoCount(PseudoCount< ALLOC > &&from)
move constructor
virtual std::size_t minNbRowsPerThread() const
returns the minimum of rows that each thread should process
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)
virtual std::size_t nbThreads() const
returns the number of threads used to parse the database
virtual ~PseudoCount()
destructor
PseudoCount< ALLOC > & operator=(const PseudoCount< ALLOC > &from)
copy operator