47#ifndef GUM_LEARNING_PARAM_ESTIMATOR_H
48#define GUM_LEARNING_PARAM_ESTIMATOR_H
97 const Prior& external_prior,
98 const Prior& _score_internal_prior,
99 const std::vector< std::pair< std::size_t, std::size_t > >&
ranges,
120 const Prior& external_prior,
121 const Prior& _score_internal_prior,
182 void setRanges(
const std::vector< std::pair< std::size_t, std::size_t > >& new_ranges);
188 const std::vector< std::pair< std::size_t, std::size_t > >&
ranges()
const;
194 std::pair< std::vector< double >,
double >
204 const std::vector< NodeId >& conditioning_nodes)
219 virtual std::pair< std::vector< double >,
double >
221 const std::vector< NodeId >& conditioning_nodes)
240 template <
typename GUM_SCALAR >
242 const std::vector< NodeId >& conditioning_nodes,
243 Tensor< GUM_SCALAR >& pot,
244 const bool compute_log_likelihood =
false);
259 template <
typename GUM_SCALAR >
286#ifndef DOXYGEN_SHOULD_SKIP_THIS
290 template <
typename GUM_SCALAR >
291 void _checkParameters_(
const NodeId target_node,
292 const std::vector< NodeId >& conditioning_nodes,
293 Tensor< GUM_SCALAR >& pot);
298 template <
typename GUM_SCALAR >
299 typename std::enable_if< !std::is_same< GUM_SCALAR, double >::value,
double >::type
300 _setParameters_(
const NodeId target_node,
301 const std::vector< NodeId >& conditioning_nodes,
302 Tensor< GUM_SCALAR >& pot,
303 const bool compute_log_likelihood);
308 template <
typename GUM_SCALAR >
309 typename std::enable_if< std::is_same< GUM_SCALAR, double >::value,
double >::type
310 _setParameters_(
const NodeId target_node,
311 const std::vector< NodeId >& conditioning_nodes,
312 Tensor< GUM_SCALAR >& pot,
313 const bool compute_log_likelihood);
A class that, given a structure and a parameter estimator returns a full Bayes net.
the class used to read a row in the database and to transform it into a set of DBRow instances that c...
The class representing a tabular database as used by learning tasks.
RecordCounter counter_
the record counter used to parse the database
ParamEstimator & operator=(const ParamEstimator &from)
copy operator
virtual std::vector< double > parameters(const NodeId target_node, const std::vector< NodeId > &conditioning_nodes)=0
returns the CPT's parameters corresponding to a given nodeset
void clearRanges()
reset the ranges to the one range corresponding to the whole database
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 > & nodeId2Columns() const
returns the mapping from ids to column positions in the database
virtual bool isGumNumberOfThreadsOverriden() const
indicates whether the user set herself the number of threads
ParamEstimator(const DBRowGeneratorParser &parser, const Prior &external_prior, const Prior &_score_internal_prior, const std::vector< std::pair< std::size_t, std::size_t > > &ranges, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
virtual ~ParamEstimator()
destructor
double setParameters(const NodeId target_node, const std::vector< NodeId > &conditioning_nodes, Tensor< GUM_SCALAR > &pot, const bool compute_log_likelihood=false)
sets a CPT's parameters and, possibly, return its log-likelihhod
virtual Size getNumberOfThreads() const
returns the current max number of threads of the scheduler
ParamEstimator(ParamEstimator &&from)
move constructor
ParamEstimator(const ParamEstimator &from)
copy constructor
const std::vector< NodeId > empty_nodevect_
an empty vector of nodes, used for empty conditioning
Prior * score_internal_prior_
if a score was used for learning the structure of the PGM, this is the priori internal to the score
ParamEstimator(const DBRowGeneratorParser &parser, const Prior &external_prior, const Prior &_score_internal_prior, const Bijection< NodeId, std::size_t > &nodeId2columns=Bijection< NodeId, std::size_t >())
default constructor
virtual void clear()
clears all the data structures from memory
void setBayesNet(const BayesNet< GUM_SCALAR > &new_bn)
assign a new Bayes net to all the counter's generators depending on a BN
std::pair< std::vector< double >, double > parametersAndLogLikelihood(const NodeId target_node)
returns the parameters of a CPT as well as its log-likelihood
virtual std::pair< std::vector< double >, double > parametersAndLogLikelihood(const NodeId target_node, const std::vector< NodeId > &conditioning_nodes)=0
returns the parameters of a CPT as well as its log-likelihood
void setRanges(const std::vector< std::pair< std::size_t, std::size_t > > &new_ranges)
sets new ranges to perform the counts used by the parameter estimator
virtual ParamEstimator * clone() const =0
virtual copy constructor
const std::vector< std::pair< std::size_t, std::size_t > > & ranges() const
returns the current ranges
ParamEstimator & operator=(ParamEstimator &&from)
move operator
std::vector< double > parameters(const NodeId target_node)
returns the CPT's parameters corresponding to a given target node
virtual void setNumberOfThreads(Size nb)
sets the number max of threads that can be used
const DatabaseTable & database() const
returns the database on which we perform the counts
virtual std::size_t minNbRowsPerThread() const
returns the minimum of rows that each thread should process
Prior * external_prior_
an external a priori
the base class for all a priori
The class that computes counting of observations from the database.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size NodeId
Type for node ids.
include the inlined functions if necessary
gum is the global namespace for all aGrUM entities
the base class for estimating parameters of CPTs
the base class for estimating parameters of CPTs
the base class for all a priori
The class that computes counting of observations from the database.