aGrUM  0.13.2
gum::learning::ParamEstimatorML< IdSetAlloc, CountAlloc > Class Template Reference

The class for estimating parameters of CPTs using Maximum LikelihoodThe class should be used as follows: first, to speed-up computations, you should consider computing all the parameters you need in one pass. More...

#include <paramEstimatorML.h>

+ Inheritance diagram for gum::learning::ParamEstimatorML< IdSetAlloc, CountAlloc >:
+ Collaboration diagram for gum::learning::ParamEstimatorML< IdSetAlloc, CountAlloc >:

Public Member Functions

Constructors / Destructors
template<typename RowFilter >
 ParamEstimatorML (const RowFilter &filter, const std::vector< Size > &var_modalities, Apriori< IdSetAlloc, CountAlloc > &apriori, const ScoreInternalApriori< IdSetAlloc, CountAlloc > &score_internal_apriori=ScoreInternalNoApriori< IdSetAlloc, CountAlloc >())
 default constructor More...
 
 ParamEstimatorML (const ParamEstimatorML< IdSetAlloc, CountAlloc > &)
 copy constructor More...
 
 ParamEstimatorML (ParamEstimatorML< IdSetAlloc, CountAlloc > &&)
 move constructor More...
 
virtual ParamEstimatorML< IdSetAlloc, CountAlloc > * copyFactory () const
 virtual copy factory More...
 
virtual ~ParamEstimatorML ()
 destructor More...
 
Accessors / Modifiers
const std::vector< double, CountAlloc > & parameters (Idx nodeset_index)
 returns the CPT's parameters corresponding to a given nodeset More...
 
Accessors / Modifiers
Idx addNodeSet (Idx var)
 add a new CPT with a single variable to be estimated More...
 
Idx addNodeSet (Idx var, const std::vector< Idx > &conditioning_ids)
 add a new target variable plus some conditioning vars More...
 
void clear ()
 clears all the data structures from memory More...
 
void setParameters (Idx nodeset_index, Potential< double > &pot)
 sets the CPT's parameters corresponding to a given nodeset More...
 
template<typename GUM_SCALAR >
void setParameters (Idx nodeset_index, Potential< GUM_SCALAR > &pot)
 sets the CPT's parameters corresponding to a given nodeset More...
 
void setRange (Size min_range, Size max_range)
 sets the range of records taken into account by the counter More...
 

Protected Attributes

Apriori< IdSetAlloc, CountAlloc > * _apriori
 the a priori used by the score More...
 
ScoreInternalApriori< IdSetAlloc, CountAlloc > * _score_internal_apriori
 the score that was use for structure learning (used for its apriori) More...
 
std::vector< bool_is_normalized
 indicate whether we have already normalized the parameters More...
 

Protected Member Functions

const std::vector< double, CountAlloc > & _getAllApriori (Idx index)
 returns the apriori vector for a given (conditioned) target set More...
 
const std::vector< double, CountAlloc > & _getConditioningApriori (Idx index)
 returns the apriori vector for a conditioning set More...
 
void _insertScoreApriori ()
 if needed insert the score apriori into the countings More...
 

Detailed Description

template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
class gum::learning::ParamEstimatorML< IdSetAlloc, CountAlloc >

The class for estimating parameters of CPTs using Maximum Likelihood

The class should be used as follows: first, to speed-up computations, you should consider computing all the parameters you need in one pass.

To do so, use the appropriate addNodeSet methods. These will compute everything you need. The addNodeSet methods where you do not specify a set of conditioning nodes assume that this set is empty. Once the computations have been performed, use method parameters to retrieve the parameters of interest.

Definition at line 65 of file paramEstimatorML.h.

Constructor & Destructor Documentation

template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
template<typename RowFilter >
gum::learning::ParamEstimatorML< IdSetAlloc, CountAlloc >::ParamEstimatorML ( const RowFilter &  filter,
const std::vector< Size > &  var_modalities,
Apriori< IdSetAlloc, CountAlloc > &  apriori,
const ScoreInternalApriori< IdSetAlloc, CountAlloc > &  score_internal_apriori = ScoreInternalNoApriori< IdSetAlloc, CountAlloc >() 
)

default constructor

Parameters
filterthe row filter that will be used to read the database
var_modalitiesthe domain sizes of the variables in the database
aprioriThe parameter apriori.
score_internal_aprioriThe score internal apriori.
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
gum::learning::ParamEstimatorML< IdSetAlloc, CountAlloc >::ParamEstimatorML ( const ParamEstimatorML< IdSetAlloc, CountAlloc > &  )

copy constructor

template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
gum::learning::ParamEstimatorML< IdSetAlloc, CountAlloc >::ParamEstimatorML ( ParamEstimatorML< IdSetAlloc, CountAlloc > &&  )

move constructor

template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
virtual gum::learning::ParamEstimatorML< IdSetAlloc, CountAlloc >::~ParamEstimatorML ( )
virtual

destructor

Member Function Documentation

template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
const std::vector< double, CountAlloc >& gum::learning::ParamEstimator< IdSetAlloc, CountAlloc >::_getAllApriori ( Idx  index)
protectedinherited

returns the apriori vector for a given (conditioned) target set

This method returns the observation countings for the set of variables whose index was returned by method addNodeSet. If the set was conditioned, the countings correspond to the target variables and the conditioning variables. If you wish to get only the countings for the conditioning variables, prefer using method _getConditioningApriori.

Warning
the dimensions of the vector are as follows: first come the nodes of the conditioning set (in the order in which they were specified when callind addNodeset, and then the target nodes.
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
const std::vector< double, CountAlloc >& gum::learning::ParamEstimator< IdSetAlloc, CountAlloc >::_getConditioningApriori ( Idx  index)
protectedinherited

returns the apriori vector for a conditioning set

template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
void gum::learning::ParamEstimator< IdSetAlloc, CountAlloc >::_insertScoreApriori ( )
protectedinherited

if needed insert the score apriori into the countings

template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
Idx gum::learning::ParamEstimator< IdSetAlloc, CountAlloc >::addNodeSet ( Idx  var)
inherited

add a new CPT with a single variable to be estimated

Parameters
varrepresents the index of the variable in the filtered rows produced by the database cell filters whose observations shall be counted
Returns
the index of the produced counting vector: the user should use class ParamEstimator to compute in one pass several CPT's parameters. These and their corresponding countings in the database are stored into a vector and the value returned by method addNodeSet is the index of the observed countings of "var" in this vector. The user shall pass this index as argument to methods _getAllCounts and _getConditioningCounts to get the corresponding counting vectors.
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
Idx gum::learning::ParamEstimator< IdSetAlloc, CountAlloc >::addNodeSet ( Idx  var,
const std::vector< Idx > &  conditioning_ids 
)
inherited

add a new target variable plus some conditioning vars

Parameters
varrepresents the index of the target variable in the filtered rows produced by the database cell filters
conditioning_idsthe indices of the variables of the conditioning set in the filtered rows
Returns
the index of the produced counting vector: the user should use class ParamEstimator to compute in one pass several CPT's parameters. These and their corresponding countings in the database are stored into a vector and the value returned by method addNodeSet is the index of the observed countings of "var" in this vector. The user shall pass this index as argument to methods _getAllCounts and _getConditioningCounts to get the corresponding counting vectors.
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
void gum::learning::ParamEstimator< IdSetAlloc, CountAlloc >::clear ( )
inherited

clears all the data structures from memory

template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
virtual ParamEstimatorML< IdSetAlloc, CountAlloc >* gum::learning::ParamEstimatorML< IdSetAlloc, CountAlloc >::copyFactory ( ) const
virtual
template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
const std::vector< double, CountAlloc >& gum::learning::ParamEstimatorML< IdSetAlloc, CountAlloc >::parameters ( Idx  nodeset_index)
virtual

returns the CPT's parameters corresponding to a given nodeset

The vector contains the parameters of an n-dimensional CPT. The distribution of the dimensions of the CPT within the vector is as follows: first, there are the conditioning nodes (in the order in which they were specified) and, then, the target node.

Exceptions
CPTErroris raised if some values of the conditioning sets were not observed in the database.

Implements gum::learning::ParamEstimator< IdSetAlloc, CountAlloc >.

template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
void gum::learning::ParamEstimator< IdSetAlloc, CountAlloc >::setParameters ( Idx  nodeset_index,
Potential< double > &  pot 
)
inherited

sets the CPT's parameters corresponding to a given nodeset

The order of the variables in the potential and in the nodeset are assumed to be identical

template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
template<typename GUM_SCALAR >
void gum::learning::ParamEstimator< IdSetAlloc, CountAlloc >::setParameters ( Idx  nodeset_index,
Potential< GUM_SCALAR > &  pot 
)
inherited

sets the CPT's parameters corresponding to a given nodeset

The order of the variables in the potential and in the nodeset are assumed to be identical

template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
void gum::learning::ParamEstimator< IdSetAlloc, CountAlloc >::setRange ( Size  min_range,
Size  max_range 
)
inherited

sets the range of records taken into account by the counter

Parameters
min_rangehe number of the first record to be taken into account during learning
max_rangethe number of the record after the last one taken into account

Member Data Documentation

template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
Apriori< IdSetAlloc, CountAlloc >* gum::learning::ParamEstimator< IdSetAlloc, CountAlloc >::_apriori
protectedinherited

the a priori used by the score

Definition at line 177 of file paramEstimator.h.

template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
std::vector< bool > gum::learning::ParamEstimator< IdSetAlloc, CountAlloc >::_is_normalized
protectedinherited

indicate whether we have already normalized the parameters

Definition at line 183 of file paramEstimator.h.

template<typename IdSetAlloc = std::allocator< Idx >, typename CountAlloc = std::allocator< double >>
ScoreInternalApriori< IdSetAlloc, CountAlloc >* gum::learning::ParamEstimator< IdSetAlloc, CountAlloc >::_score_internal_apriori
protectedinherited

the score that was use for structure learning (used for its apriori)

Definition at line 180 of file paramEstimator.h.


The documentation for this class was generated from the following file: