27 #ifndef GUM_LEARNING_PARAM_ESTIMATOR_H 28 #define GUM_LEARNING_PARAM_ESTIMATOR_H 30 #include <type_traits> 32 #include <agrum/agrum.h> 33 #include <agrum/tools/database/databaseTable.h> 34 #include <agrum/BN/learning/aprioris/apriori.h> 35 #include <agrum/tools/stattests/recordCounter.h> 36 #include <agrum/tools/multidim/potential.h> 48 template <
template <
typename >
class ALLOC =
std::
allocator >
84 const DBRowGeneratorParser< ALLOC >& parser,
85 const Apriori< ALLOC >& external_apriori,
86 const Apriori< ALLOC >& score_internal__apriori,
114 const Apriori< ALLOC >& external_apriori,
115 const Apriori< ALLOC >& score_internal__apriori,
126 const allocator_type& alloc);
132 ParamEstimator(ParamEstimator< ALLOC >&& from,
const allocator_type& alloc);
153 virtual void clear();
182 template <
template <
typename >
class XALLOC >
214 template <
typename GUM_SCALAR >
216 const NodeId target_node,
234 template <
typename GUM_SCALAR >
235 void setBayesNet(
const BayesNet< GUM_SCALAR >& new_bn);
264 #ifndef DOXYGEN_SHOULD_SKIP_THIS 268 template <
typename GUM_SCALAR >
269 void checkParameters__(
270 const NodeId target_node,
271 const std::vector< NodeId, ALLOC< NodeId > >& conditioning_nodes,
272 Potential< GUM_SCALAR >& pot);
277 template <
typename GUM_SCALAR >
278 typename std::enable_if< !std::is_same< GUM_SCALAR,
double >::value,
281 const NodeId target_node,
282 const std::vector< NodeId, ALLOC< NodeId > >& conditioning_nodes,
283 Potential< GUM_SCALAR >& pot);
288 template <
typename GUM_SCALAR >
289 typename std::enable_if< std::is_same< GUM_SCALAR,
double >::value,
292 const NodeId target_node,
293 const std::vector< NodeId, ALLOC< NodeId > >& conditioning_nodes,
294 Potential< GUM_SCALAR >& pot);
304 #include <agrum/BN/learning/paramUtils/paramEstimator_tpl.h> ParamEstimator< ALLOC > & operator=(const ParamEstimator< ALLOC > &from)
copy operator
virtual std::vector< double, ALLOC< double > > parameters(const NodeId target_node, const std::vector< NodeId, ALLOC< NodeId > > &conditioning_nodes)=0
returns the CPT's parameters corresponding to a given nodeset
const Bijection< NodeId, std::size_t, ALLOC< std::size_t > > & nodeId2Columns() const
returns the mapping from ids to column positions in the database
void setParameters(const NodeId target_node, const std::vector< NodeId, ALLOC< NodeId > > &conditioning_nodes, Potential< GUM_SCALAR > &pot)
sets the CPT's parameters corresponding to a given Potential
ParamEstimator(const ParamEstimator< ALLOC > &from, const allocator_type &alloc)
copy constructor with a given allocator
ParamEstimator(const ParamEstimator< ALLOC > &from)
copy constructor
void clearRanges()
reset the ranges to the one range corresponding to the whole database
ParamEstimator(const DBRowGeneratorParser< ALLOC > &parser, const Apriori< ALLOC > &external_apriori, const Apriori< ALLOC > &score_internal__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
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 parameter estimator
INLINE void emplace(Args &&... args)
ParamEstimator< ALLOC > & operator=(ParamEstimator< ALLOC > &&from)
move operator
ParamEstimator(ParamEstimator< ALLOC > &&from)
move constructor
void setBayesNet(const BayesNet< GUM_SCALAR > &new_bn)
assign a new Bayes net to all the counter's generators depending on a BN
ParamEstimator(const DBRowGeneratorParser< ALLOC > &parser, const Apriori< ALLOC > &external_apriori, const Apriori< ALLOC > &score_internal__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
Apriori< ALLOC > * score_internal_apriori_
if a score was used for learning the structure of the PGM, this is the a priori internal to the score...
allocator_type getAllocator() const
returns the allocator used by the score
virtual void setMinNbRowsPerThread(const std::size_t nb) const
changes the number min of rows a thread should process in a multithreading context ...
virtual ParamEstimator< ALLOC > * clone(const allocator_type &alloc) const =0
virtual copy constructor with a given allocator
virtual ~ParamEstimator()
destructor
const DatabaseTable< ALLOC > & database() const
returns the database on which we perform the counts
std::vector< double, ALLOC< double > > parameters(const NodeId target_node)
returns the CPT's parameters corresponding to a given target node
virtual void clear()
clears all the data structures from memory
virtual std::size_t nbThreads() const
returns the number of threads used to parse the database
virtual ParamEstimator< ALLOC > * clone() const =0
virtual copy constructor
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)
virtual void setMaxNbThreads(std::size_t nb) const
changes the max number of threads used to parse the database
virtual std::size_t minNbRowsPerThread() const
returns the minimum of rows that each thread should process
RecordCounter< ALLOC > counter_
the record counter used to parse the database
Apriori< ALLOC > * external_apriori_
an external a priori
ParamEstimator(ParamEstimator< ALLOC > &&from, const allocator_type &alloc)
move constructor with a given allocator