25 #ifndef GUM_LEARNING_SCORE_H 26 #define GUM_LEARNING_SCORE_H 48 template <
template <
typename >
class ALLOC = std::allocator >
83 const std::vector< std::pair< std::size_t, std::size_t >,
84 ALLOC< std::pair< std::size_t, std::size_t > > >&
159 template <
template <
typename >
class XALLOC >
161 const std::vector< std::pair< std::size_t, std::size_t >,
162 XALLOC< std::pair< std::size_t, std::size_t > > >&
169 const std::vector< std::pair< std::size_t, std::size_t >,
170 ALLOC< std::pair< std::size_t, std::size_t > > >&
181 const std::vector<
NodeId, ALLOC< NodeId > >& rhs_ids);
283 std::vector< double, ALLOC< double > >
285 const std::vector<
double, ALLOC< double > >& N_xyz)
const;
293 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
const DatabaseTable< ALLOC > & database() const
return the database used by the score
double score(const NodeId var)
returns the score of a single node
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 score
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
The base class for all the scores used for learning (BIC, BDeu, etc)
the classes to account for structure changes in a graph
Score(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
virtual void setMaxNbThreads(std::size_t nb) const
changes the max number of threads used to parse the database
the base class for all a priori
const double _1log2
1 / log(2)
virtual std::size_t minNbRowsPerThread() const
returns the minimum of rows that each thread should process
A class for storing a pair of sets of NodeIds, the second one corresponding to a conditional set...
the base class for all a priori
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
gum is the global namespace for all aGrUM entities
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
ScoringCache< ALLOC > _cache
the scoring cache
const std::vector< NodeId, ALLOC< NodeId > > _empty_ids
an empty vector
std::vector< double, ALLOC< double > > _marginalize(const NodeId X_id, const std::vector< double, ALLOC< double > > &N_xyz) const
returns a counting vector where variables are marginalized from N_xyz
The class that computes countings of observations from the database.
virtual std::size_t nbThreads() const
returns the number of threads used to parse the database
The class that computes countings of observations from the database.
a cache for caching scores and independence tests results
virtual ~Score()
destructor
Score< ALLOC > & operator=(const Score< ALLOC > &from)
copy operator
void clear()
clears all the data structures from memory, including the cache
Set of pairs of elements with fast search for both elements.
virtual const Apriori< ALLOC > & internalApriori() const =0
returns the internal apriori of the score
virtual double _score(const IdSet< ALLOC > &idset)=0
returns the score for a given IdSet
The class representing a tabular database as used by learning tasks.
bool isUsingCache() const
indicates whether the score uses a cache
void clearCache()
clears the current cache
a cache for caching scores and independence tests resultsCaching previously computed scores or the re...
virtual std::string isAprioriCompatible() const =0
indicates whether the apriori is compatible (meaningful) with the score
void useCache(const bool on_off)
turn on/off the use of a cache of the previously computed score
void clearRanges()
reset the ranges to the one range corresponding to the whole database
allocator_type getAllocator() const
returns the allocator used by the score
the base class for all the scores used for learning (BIC, BDeu, etc)
bool _use_cache
a Boolean indicating whether we wish to use the cache
virtual void setMinNbRowsPerThread(const std::size_t nb) const
changes the number min of rows a thread should process in a multithreading context ...
Apriori< ALLOC > * _apriori
the expert knowledge a priori we add to the score
RecordCounter< ALLOC > _counter
the record counter used for the countings over discrete variables
virtual Score< ALLOC > * clone() const =0
virtual copy constructor
the class used to read a row in the database and to transform it into a set of DBRow instances that c...
Size NodeId
Type for node ids.