28 #ifndef GUM_LEARNING_PARAM_ESTIMATOR_H 29 #define GUM_LEARNING_PARAM_ESTIMATOR_H 31 #include <type_traits> 49 template <
template <
typename >
class ALLOC = std::allocator >
88 const std::vector< std::pair< std::size_t, std::size_t >,
89 ALLOC< std::pair< std::size_t, std::size_t > > >&
155 virtual void clear();
184 template <
template <
typename >
class XALLOC >
186 const std::vector< std::pair< std::size_t, std::size_t >,
187 XALLOC< std::pair< std::size_t, std::size_t > > >&
194 const std::vector< std::pair< std::size_t, std::size_t >,
195 ALLOC< std::pair< std::size_t, std::size_t > > >&
199 std::vector< double, ALLOC< double > >
parameters(
const NodeId target_node);
207 virtual std::vector< double, ALLOC< double > >
parameters(
209 const std::vector<
NodeId, ALLOC< NodeId > >& conditioning_nodes) = 0;
215 template <
typename GUM_SCALAR >
218 const std::vector<
NodeId, ALLOC< NodeId > >& conditioning_nodes,
235 template <
typename GUM_SCALAR >
265 #ifndef DOXYGEN_SHOULD_SKIP_THIS 269 template <
typename GUM_SCALAR >
270 void __checkParameters(
272 const std::vector<
NodeId, ALLOC< NodeId > >& conditioning_nodes,
278 template <
typename GUM_SCALAR >
279 typename std::enable_if< !std::is_same< GUM_SCALAR, double >::value,
283 const std::vector<
NodeId, ALLOC< NodeId > >& conditioning_nodes,
289 template <
typename GUM_SCALAR >
290 typename std::enable_if< std::is_same< GUM_SCALAR, double >::value,
294 const std::vector<
NodeId, ALLOC< NodeId > >& conditioning_nodes,
ParamEstimator< ALLOC > & operator=(const ParamEstimator< ALLOC > &from)
copy operator
aGrUM's Potential is a multi-dimensional array with tensor operators.
Class representing a Bayesian Network.
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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
the base class for all a priori
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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
void setBayesNet(const BayesNet< GUM_SCALAR > &new_bn)
assign a new Bayes net to all the counter's generators depending on a BN
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...
Apriori< ALLOC > * _external_apriori
an external a priori
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
allocator_type getAllocator() const
returns the allocator used by the score
The class that computes countings of observations from the database.
virtual void setMinNbRowsPerThread(const std::size_t nb) const
changes the number min of rows a thread should process in a multithreading context ...
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual ~ParamEstimator()
destructor
Set of pairs of elements with fast search for both elements.
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
The class representing a tabular database as used by learning tasks.
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
ALLOC< NodeId > allocator_type
type for the allocators passed in arguments of methods
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
The base class for estimating parameters of CPTs.
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.
RecordCounter< ALLOC > _counter
the record counter used to parse the database
const std::vector< NodeId, ALLOC< NodeId > > _empty_nodevect
an empty vector of nodes, used for empty conditioning