STK++ 0.9.13
|
Main class for handling composed mixture models. More...
#include <STK_MixtureComposer.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 | |
MixtureComposer (int nbSample, int nbCluster) | |
Constructor. | |
MixtureComposer (MixtureComposer const &composer) | |
copy constructor. | |
virtual | ~MixtureComposer () |
The registered mixtures will be deleted there. | |
virtual MixtureComposer * | create () const |
Create a composer, but reinitialize the mixtures parameters. | |
virtual MixtureComposer * | 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 proportions and the model parameters given the current tik mixture parameters. | |
virtual void | imputationStep () |
Impute the missing values. | |
virtual void | samplingStep () |
Simulation of all the latent variables and/or missing data excluding class labels. | |
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 | ~IMixtureComposer () |
destructor | |
Clust::modelState | state () const |
void | setState (Clust::modelState state) |
set the state of the model : should be used by any strategy | |
virtual int | cStep () |
Replace tik by zik. | |
virtual int | sStep () |
Simulate zi accordingly to tik and replace tik by zik by calling cStep(). | |
virtual Real | eStep () |
compute the zi, the lnLikelihood of the current estimates and the next value of the tik. | |
virtual void | mapStep () |
Compute zi using the Map estimate. | |
virtual void | pStep () |
Compute proportions using the ML estimates, default implementation. | |
virtual void | initializeStep () |
Initialize the model before its first use. | |
void | randomClassInit () |
Initialize randomly the labels zi of the model. | |
void | randomFuzzyInit () |
Initialize randomly the posterior probabilities tik of the model, then compute the zi values with mapStep, compute the initial parameter values using paramUpdateStep, and compute the tik using eStep(). | |
![]() | |
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. | |
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 | createComposer (std::vector< IMixture * > const &v_mixtures_) |
Create the composer using existing data handler and mixtures. | |
![]() | |
IMixtureComposer (int nbSample, int nbCluster) | |
Constructor. | |
IMixtureComposer (IMixtureComposer const &model) | |
copy constructor. | |
void | sStep (int i) |
Simulate zi accordingly to tik. | |
void | cStep (int i) |
Replace tik by zik. | |
Real | eStep (int i) |
compute one zi and the next value of the tik for i fixed | |
void | mapStep (int i) |
Compute zi using the Map estimate for i fixed. | |
virtual void | initializeMixtureParameters () |
Create the mixture model parameters pk_ and tik_. | |
virtual int | randomTik () |
generate random tik_ | |
virtual int | randomZi () |
generate random zi_ | |
![]() | |
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 | |
Protected Attributes | |
Real | meanlnLikelihood_ |
averaged lnLikelihood values. | |
![]() | |
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 handling composed mixture models.
A composed mixture model on some composed space
The
The MixtureComposer class is a final class implementing the features requested by the interface class IMixtureComposer.
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 69 of file STK_MixtureComposer.h.
typedef std::vector<IMixture*>::const_iterator STK::MixtureComposer::ConstMixtIterator |
Definition at line 72 of file STK_MixtureComposer.h.
typedef std::vector<IMixture*>::iterator STK::MixtureComposer::MixtIterator |
Definition at line 73 of file STK_MixtureComposer.h.
Constructor.
nbCluster,nbSample | number of clusters and samples. |
Definition at line 45 of file STK_MixtureComposer.cpp.
References STK::IMixtureStatModel::nbCluster(), and STK::IStatModelBase::setNbFreeParameter().
STK::MixtureComposer::MixtureComposer | ( | MixtureComposer const & | composer | ) |
copy constructor.
composer | the composer to copy |
Definition at line 53 of file STK_MixtureComposer.cpp.
|
virtual |
The registered mixtures will be deleted there.
Definition at line 59 of file STK_MixtureComposer.cpp.
|
virtual |
Create a clone of the current model, with mixtures parameters preserved.
Implements STK::IMixtureComposer.
Reimplemented in STK::MixtureComposerFixedProp, STK::MixtureSemiLearner, and STK::MixtureSemiLearnerFixedProp.
Definition at line 62 of file STK_MixtureComposer.cpp.
|
virtual |
Create a composer, but reinitialize the mixtures parameters.
Implements STK::IMixtureComposer.
Reimplemented in STK::MixtureComposerFixedProp, STK::MixtureSemiLearner, and STK::MixtureSemiLearnerFixedProp.
Definition at line 65 of file STK_MixtureComposer.cpp.
References createComposer(), STK::IMixtureStatModel::nbCluster(), STK::IStatModelBase::nbSample(), and STK::IMixtureStatModel::v_mixtures_.
|
protected |
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 190 of file STK_MixtureComposer.cpp.
References STK::IMixtureComposer::initializeStep(), STK::IMixtureStatModel::v_mixtures(), and STK::IMixtureStatModel::v_mixtures_.
Referenced by create(), STK::MixtureComposerFixedProp::create(), STK::MixtureSemiLearner::create(), and STK::MixtureSemiLearnerFixedProp::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::IMixtureComposer.
Definition at line 181 of file STK_MixtureComposer.cpp.
References STK::IRegression< YArray, XArray, Weights >::finalizeStep(), and STK::IMixtureStatModel::v_mixtures_.
|
virtual |
Impute the missing values.
Reimplemented from STK::IMixtureStatModel.
Definition at line 134 of file STK_MixtureComposer.cpp.
References STK::IMixtureStatModel::v_mixtures_.
i,k | indexes of the sample and components |
Implements STK::IMixtureStatModel.
Definition at line 73 of file STK_MixtureComposer.cpp.
References STK::sum(), and STK::IMixtureStatModel::v_mixtures_.
Referenced by STK::MixtureSemiLearner::eStep().
|
virtual |
Compute the proportions and the model parameters given the current tik mixture parameters.
Implements STK::IMixtureComposer.
Definition at line 81 of file STK_MixtureComposer.cpp.
References _T, stk_cout, and STK::IMixtureStatModel::v_mixtures_.
|
virtual |
initialize randomly the parameters of the components of the model
Implements STK::IMixtureComposer.
Definition at line 110 of file STK_MixtureComposer.cpp.
References _T, STK::IMixtureComposer::eStep(), STK::IMixtureComposer::initializeStep(), STK::IMixtureComposer::mapStep(), STK::Clust::modelInitialized_, STK::Clust::modelParamInitialized_, STK::Clust::randomParamInitFail_, STK::IMixtureComposer::randomTik(), STK::IMixtureComposer::setState(), STK::IMixtureComposer::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 164 of file STK_MixtureComposer.cpp.
References meanlnLikelihood_, and STK::IMixtureStatModel::v_mixtures_.
|
virtual |
Simulation of all the latent variables and/or missing data excluding class labels.
Reimplemented from STK::IMixtureStatModel.
Definition at line 143 of file STK_MixtureComposer.cpp.
References _T, stk_cout, and 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 172 of file STK_MixtureComposer.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 157 of file STK_MixtureComposer.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 93 of file STK_MixtureComposer.cpp.
References _T, STK::IMixtureStatModel::computeNbMissingValues(), STK::IStatModelBase::lnLikelihood(), STK::IMixtureStatModel::nbCluster(), STK::IStatModelBase::nbFreeParameter(), STK::IStatModelBase::nbSample(), STK::IMixtureStatModel::pk(), and STK::IMixtureStatModel::v_mixtures_.
|
protected |
averaged lnLikelihood values.
Will be used by the storeIntermediateResults method.
Definition at line 138 of file STK_MixtureComposer.h.
Referenced by releaseIntermediateResults(), setParametersStep(), and storeIntermediateResults().