STK++ 0.9.13
|
Main class for learning mixture models. More...
#include <STK_MixtureLearner.h>
Public Types | |
typedef std::vector< IMixture * >::const_iterator | ConstMixtIterator |
typedef std::vector< IMixture * >::iterator | MixtIterator |
![]() | |
typedef std::vector< IMixture * >::const_iterator | ConstMixtIterator |
typedef std::vector< IMixture * >::iterator | MixtIterator |
Public Member Functions | |
MixtureLearner (int nbSample, int nbCluster) | |
Constructor. | |
MixtureLearner (MixtureLearner const &composer) | |
copy constructor. | |
virtual | ~MixtureLearner () |
The registered mixtures will be deleted there. | |
virtual MixtureLearner * | create () const |
Create a composer, but reinitialize the mixtures parameters. | |
virtual MixtureLearner * | clone () const |
Create a clone of the current model, with mixtures parameters preserved. | |
virtual Real | lnComponentProbability (int i, int k) const |
virtual void | writeParameters (ostream &os) const |
write the parameters of the model in the stream os. | |
virtual void | randomInit () |
initialize randomly the parameters of the components of the model | |
virtual void | paramUpdateStep () |
Compute the model parameters given the current imputed/simulated missing values. | |
virtual void | imputationStep () |
Impute the data missing values. | |
virtual void | samplingStep () |
Simulation of all the data missing values. | |
virtual void | storeIntermediateResults (int iteration) |
This step can be used to signal to the mixtures that they must store results. | |
virtual void | releaseIntermediateResults () |
This step can be used to signal to the mixtures that they must release the stored results. | |
virtual void | setParametersStep () |
Utility method allowing to signal to a mixture to set its parameters. | |
virtual void | finalizeStep () |
This step can be used by developer to finalize any thing. | |
![]() | |
virtual | ~IMixtureLearner () |
destructor | |
CVectorXi const & | ziPred () const |
Clust::modelState | state () const |
void | setState (Clust::modelState state) |
set the state of the model : should be used by any strategy | |
virtual void | mapStep () |
Compute ziPred using the Map estimate. | |
template<class ColVector > | |
void | setClassLabels (ColVector const &zi) |
set the mixture parameters using the given class labels. | |
template<class ColVector , class RowVector > | |
void | setClassLabels (ColVector const &zi, RowVector const &pk) |
set the mixture parameters using the class labels and giving the proportions. | |
![]() | |
virtual | ~IMixtureStatModel () |
destructor | |
int | nbCluster () const |
CPointX const & | pk () const |
CArrayXX const & | tik () const |
CPointX const & | tk () const |
CVectorXi const & | zi () const |
std::vector< IMixture * > const & | v_mixtures () const |
Real | computeLnLikelihood (int i) const |
Real | computeLikelihood (int i) const |
Real | computeLnLikelihood () const |
Real | computeICL () const |
IMixture * | getMixture (String const &idData) const |
Utility lookup function allowing to find a Mixture from its idData. | |
void | registerMixture (IMixture *p_mixture) |
register a mixture to the composer. | |
void | releaseMixture (String const &idData) |
release a mixture from the composer. | |
int | computeNbFreeParameters () const |
compute the number of free parameters of the model. | |
int | computeNbMissingValues () const |
compute the missing values of the model. | |
virtual void | initializeStep () |
Initialize the model before at its first use. | |
template<class Array > | |
void | setMixtureParameters (Array const &tik) |
set the mixture parameters using an array of posterior probabilities. | |
template<class Array , class RowVector > | |
void | setMixtureParameters (Array const &tik, RowVector const &pk) |
set the mixture parameters giving the posterior probabilities and the proportions. | |
template<class RowVector > | |
void | setProportions (RowVector const &pk) |
Set proportions of each classes. | |
template<class Manager , class Parameters > | |
void | setParameters (IMixtureManager< Manager > const &manager, String const &idData, Parameters const ¶m) |
Utility method allowing to set the parameters to a specific mixture. | |
template<class Manager > | |
void | createMixture (IMixtureManager< Manager > &manager) |
Utility method allowing to create all the mixtures registered in the data handler of a mixture manager and to register them. | |
template<class Manager > | |
IMixture * | createMixture (IMixtureManager< Manager > &manager, String const &idData) |
Utility method allowing to create a mixture with a given data set and register it. | |
template<class Manager > | |
void | removeMixture (IMixtureManager< Manager > &manager, String const &idData) |
Utility method allowing to release completely a mixture with its data set. | |
template<class Manager , class Parameters > | |
void | getParameters (IMixtureManager< Manager > const &manager, String const &idData, Parameters ¶m) const |
Utility method allowing to get the parameters of a specific mixture. | |
template<class Manager , class MissingValues > | |
void | getMissingValues (IMixtureManager< Manager > const &manager, String const &idData, MissingValues &missing) const |
Utility method allowing to get the missing values of a specific mixture. | |
template<class DataHandler > | |
void | createMixture (IMixtureManager< DataHandler > &manager) |
![]() | |
int | nbSample () const |
Real | lnNbSample () const |
int | nbVariable () const |
Real | lnLikelihood () const |
Real | likelihood () const |
int | nbFreeParameter () const |
Real | computeBIC () const |
Real | computeAIC () const |
Real | computeML () const |
Protected Member Functions | |
void | createLearner (std::vector< IMixture * > const &v_mixtures_) |
Create the composer using existing data handler and mixtures. | |
![]() | |
IMixtureLearner (int nbSample, int nbCluster) | |
Constructor. | |
IMixtureLearner (IMixtureLearner const &model) | |
copy constructor. | |
![]() | |
IMixtureStatModel (int nbSample, int nbCluster) | |
Constructor. | |
IMixtureStatModel (IMixtureStatModel const &model) | |
copy constructor. | |
void | setNbCluster (int nbCluster) |
set the number of cluster of the model | |
![]() | |
IStatModelBase () | |
Default constructor. | |
IStatModelBase (int nbSample) | |
Constructor with specified dimension. | |
IStatModelBase (int nbSample, int nbVariable) | |
Constructor with specified dimension. | |
IStatModelBase (IStatModelBase const &model) | |
Copy constructor. | |
~IStatModelBase () | |
destructor | |
void | setNbFreeParameter (int const &nbFreeParameter) |
set the number of free parameters of the model | |
void | setNbSample (int const &nbSample) |
set the number of samples of the model | |
void | setNbVariable (int const &nbVariable) |
set the number of variables of the model | |
void | setLnLikelihood (Real const &lnLikelihood) |
set the log-likelihood of the model | |
void | initialize (int nbSample, int nbVariable) |
set the dimensions of the parameters of the model | |
Private Attributes | |
Real | meanlnLikelihood_ |
averaged lnLikelihood values. | |
Additional Inherited Members | |
![]() | |
int | nbCluster_ |
number of cluster. | |
CPointX | pk_ |
The proportions of each mixtures. | |
CArrayXX | tik_ |
The tik probabilities. | |
CPointX | tk_ |
The sum of the columns of tik_. | |
CVectorXi | zi_ |
The zi class label. | |
std::vector< IMixture * > | v_mixtures_ |
vector of pointers to the mixtures components | |
Main class for learning mixture models.
A composed mixture model on some composed space
The
The MixtureLearner class is a final class implementing the features requested by the interface class IMixtureLearner.
It uses injection dependency in order to create/release mixture and get/set parameters of a mixture. The class responsible of the injection is derived from an STK::IMixtureManager.
Definition at line 70 of file STK_MixtureLearner.h.
typedef std::vector<IMixture*>::const_iterator STK::MixtureLearner::ConstMixtIterator |
Definition at line 73 of file STK_MixtureLearner.h.
typedef std::vector<IMixture*>::iterator STK::MixtureLearner::MixtIterator |
Definition at line 74 of file STK_MixtureLearner.h.
Constructor.
nbCluster,nbSample | number of clusters and samples. |
Definition at line 46 of file STK_MixtureLearner.cpp.
References STK::IMixtureStatModel::nbCluster(), and STK::IStatModelBase::setNbFreeParameter().
STK::MixtureLearner::MixtureLearner | ( | MixtureLearner const & | composer | ) |
copy constructor.
composer | the composer to copy |
Definition at line 54 of file STK_MixtureLearner.cpp.
|
virtual |
The registered mixtures will be deleted there.
Definition at line 59 of file STK_MixtureLearner.cpp.
|
virtual |
Create a clone of the current model, with mixtures parameters preserved.
Implements STK::IMixtureStatModel.
Definition at line 62 of file STK_MixtureLearner.cpp.
|
virtual |
Create a composer, but reinitialize the mixtures parameters.
Implements STK::IMixtureStatModel.
Definition at line 65 of file STK_MixtureLearner.cpp.
References createLearner(), STK::IMixtureStatModel::nbCluster(), STK::IStatModelBase::nbSample(), and STK::IMixtureStatModel::v_mixtures_.
Create the composer using existing data handler and mixtures.
This method is essentially used by the create() method and can be reused in derived classes.
Definition at line 167 of file STK_MixtureLearner.cpp.
References STK::IMixtureStatModel::computeNbFreeParameters(), STK::IStatModelBase::initialize(), STK::IRegression< YArray, XArray, Weights >::initializeStep(), STK::IStatModelBase::nbSample(), STK::IStatModelBase::setNbFreeParameter(), STK::IMixtureStatModel::v_mixtures(), and STK::IMixtureStatModel::v_mixtures_.
Referenced by create().
|
virtual |
This step can be used by developer to finalize any thing.
It will be called only once after we finish running the estimation algorithm.
Reimplemented from STK::IMixtureStatModel.
Definition at line 158 of file STK_MixtureLearner.cpp.
References STK::IRegression< YArray, XArray, Weights >::finalizeStep(), and STK::IMixtureStatModel::v_mixtures_.
|
virtual |
Impute the data missing values.
Reimplemented from STK::IMixtureStatModel.
Definition at line 118 of file STK_MixtureLearner.cpp.
References STK::IMixtureStatModel::v_mixtures_.
i,k | indexes of the sample and of the class |
Implements STK::IMixtureStatModel.
Definition at line 73 of file STK_MixtureLearner.cpp.
References STK::sum(), and STK::IMixtureStatModel::v_mixtures_.
|
virtual |
Compute the model parameters given the current imputed/simulated missing values.
This method updates then the lnLikelihood_ of the model.
Implements STK::IMixtureLearner.
Definition at line 81 of file STK_MixtureLearner.cpp.
References STK::IMixtureStatModel::computeLnLikelihood(), STK::IStatModelBase::setLnLikelihood(), and STK::IMixtureStatModel::v_mixtures_.
|
virtual |
initialize randomly the parameters of the components of the model
Implements STK::IMixtureStatModel.
Definition at line 103 of file STK_MixtureLearner.cpp.
References _T, STK::IMixtureStatModel::initializeStep(), STK::Clust::modelParamInitialized_, STK::IMixtureLearner::setState(), STK::IMixtureLearner::state(), stk_cout, and STK::IMixtureStatModel::v_mixtures_.
|
virtual |
This step can be used to signal to the mixtures that they must release the stored results.
This is usually called if the estimation process failed.
Reimplemented from STK::IMixtureStatModel.
Definition at line 141 of file STK_MixtureLearner.cpp.
References meanlnLikelihood_, and STK::IMixtureStatModel::v_mixtures_.
|
virtual |
Simulation of all the data missing values.
Reimplemented from STK::IMixtureStatModel.
Definition at line 127 of file STK_MixtureLearner.cpp.
References STK::IMixtureStatModel::v_mixtures_.
|
virtual |
Utility method allowing to signal to a mixture to set its parameters.
It will be called once enough intermediate results have been stored.
Reimplemented from STK::IMixtureStatModel.
Definition at line 149 of file STK_MixtureLearner.cpp.
References meanlnLikelihood_, STK::IStatModelBase::setLnLikelihood(), and STK::IMixtureStatModel::v_mixtures_.
This step can be used to signal to the mixtures that they must store results.
This is usually called after a burn-in phase. The composer store the current value of the log-Likelihood.
Reimplemented from STK::IMixtureStatModel.
Definition at line 134 of file STK_MixtureLearner.cpp.
References STK::IStatModelBase::lnLikelihood(), meanlnLikelihood_, and STK::IMixtureStatModel::v_mixtures_.
write the parameters of the model in the stream os.
Reimplemented from STK::IMixtureStatModel.
Definition at line 88 of file STK_MixtureLearner.cpp.
References _T, STK::IStatModelBase::lnLikelihood(), STK::IMixtureStatModel::nbCluster(), STK::IStatModelBase::nbFreeParameter(), STK::IStatModelBase::nbSample(), STK::IMixtureStatModel::pk(), and STK::IMixtureStatModel::v_mixtures_.
|
private |
averaged lnLikelihood values.
Will be used by the storeIntermediateResults method.
Definition at line 137 of file STK_MixtureLearner.h.
Referenced by releaseIntermediateResults(), setParametersStep(), and storeIntermediateResults().