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) = 0;
218 virtual std::pair< std::vector< double >,
double >
220 const std::vector< NodeId >& conditioning_nodes) = 0;
238 template < GUM_Numeric GUM_SCALAR >
240 const std::vector< NodeId >& conditioning_nodes,
241 Tensor< GUM_SCALAR >& pot,
242 const bool compute_log_likelihood =
false);
257 template < GUM_Numeric GUM_SCALAR >
284#ifndef DOXYGEN_SHOULD_SKIP_THIS
288 template < GUM_Numeric GUM_SCALAR >
289 void _checkParameters_(
const NodeId target_node,
290 const std::vector< NodeId >& conditioning_nodes,
291 Tensor< GUM_SCALAR >& pot);
296 template < GUM_Numeric GUM_SCALAR >
297 typename std::enable_if< !std::is_same< GUM_SCALAR, double >::value,
double >::type
298 _setParameters_(
const NodeId target_node,
299 const std::vector< NodeId >& conditioning_nodes,
300 Tensor< GUM_SCALAR >& pot,
301 const bool compute_log_likelihood);
306 template < GUM_Numeric GUM_SCALAR >
307 typename std::enable_if< std::is_same< GUM_SCALAR, double >::value,
double >::type
308 _setParameters_(
const NodeId target_node,
309 const std::vector< NodeId >& conditioning_nodes,
310 Tensor< GUM_SCALAR >& pot,
311 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
bool isGumNumberOfThreadsOverriden() const override
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
ParamEstimator(const ParamEstimator &from)
copy constructor
const std::vector< NodeId > empty_nodevect_
an empty vector of nodes, used for empty conditioning
Size getNumberOfThreads() const override
returns the current max number of threads of the scheduler
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
ParamEstimator(ParamEstimator &&from) noexcept
move constructor
void setNumberOfThreads(Size nb) override
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.