STK++ 0.9.13
|
Interface base class for all the mixture models that will be processed by the composer. More...
#include <STK_IMixture.h>
Public Member Functions | |
IMixture (String const &idData=String()) | |
Constructor with identification character. | |
IMixture (IMixture const &mixture) | |
copy constructor. | |
virtual | ~IMixture () |
Virtual destructor. | |
String const & | idData () const |
IMixtureStatModel const *const | p_composer () const |
void | setMixtureModel (IMixtureStatModel const *p_composer) |
set the mixture composer to the mixture | |
virtual IMixture * | clone () const =0 |
This is a standard clone function in usual sense. | |
virtual IMixture * | create () const =0 |
This is a standard create function in usual sense. | |
virtual void | initializeStep ()=0 |
This function must be defined in derived class for initialization of the mixture parameters. | |
virtual void | randomInit ()=0 |
This function should be used in order to initialize randomly the parameters of the mixture. | |
virtual void | paramUpdateStep ()=0 |
This function is equivalent to mStep and must be defined to update parameters. | |
virtual Real | lnComponentProbability (int sample_num, int Cluster_num)=0 |
This function must be defined to return the posterior probability (PDF) for corresponding sample_num and Cluster_num. | |
virtual int | nbFreeParameter () const =0 |
This function must return the number of free parameters. | |
virtual int | nbMissingValues () const =0 |
This function must return the number of missing value in data set identified by idData_. | |
virtual void | imputationStep () |
This function should be used for Imputation of data. | |
virtual void | samplingStep () |
This function must be defined for simulation of all the latent variables and/or missing data excluding class labels. | |
virtual void | storeIntermediateResults (int iteration) |
This function should be used to store any intermediate results during various iterations after the burn-in period. | |
virtual void | releaseIntermediateResults () |
This step can be used to signal to the mixtures that they must release the stored results. | |
virtual void | setParametersStep () |
set the parameters of the model. | |
virtual void | finalizeStep () |
This step can be used by developer to finalize any thing. | |
virtual void | writeParameters (std::ostream &out) const |
This function can be used to write summary of parameters on to the output stream. | |
Protected Member Functions | |
int | nbSample () const |
This function can be used in derived classes to get number of samples. | |
int | nbCluster () const |
This function can be used in derived classes to get number of classes. | |
CPointX const * | p_pk () const |
This function can be used in derived classes to get estimated number of individuals from the framework. | |
CPointX const * | p_tk () const |
This function can be used in derived classes to get proportions from the framework. | |
CArrayXX const * | p_tik () const |
This function can be used in derived classes to get posterior probabilities from the framework. | |
CVectorXi const * | p_zi () const |
This function can be used in derived classes to get class labels from the framework. | |
Private Attributes | |
const IMixtureStatModel * | p_composer_ |
pointer on the main composer model | |
String | idData_ |
Id name of the mixture. | |
Interface base class for all the mixture models that will be processed by the composer.
Any mixture that can be used and add to a mixed model have to implement the pure virtual methods defined in this interface. With each mixture is associated a data set identified by an idData string.
Using an idData is not mandatory but is useful in case data set is stored in a DataHandler.
Definition at line 64 of file STK_IMixture.h.
Constructor with identification character.
idData | Identification string of the data associated to this mixture. |
Definition at line 45 of file STK_IMixture.cpp.
copy constructor.
mixture | the mixture to copy |
Definition at line 50 of file STK_IMixture.cpp.
|
virtual |
This is a standard clone function in usual sense.
It must be defined to provide new object of your class with values of various parameters equal to the values of calling object. In other words, this is equivalent to polymorphic copy constructor.
Implemented in STK::CategoricalBridge< Id, Data >, STK::DiagGaussianBridge< Id, Data >, STK::GammaBridge< Id, Data >, STK::HDMatrixGaussianBridge< IdRow, IdCol, Data >, STK::HDGaussianBridge< Id, Data >, STK::KmmBridge< Id, Data >, and STK::PoissonBridge< Id, Data >.
This is a standard create function in usual sense.
It must be defined to provide new object of your class with correct behavior. In other words, this is equivalent to virtual constructor.
Implemented in STK::CategoricalBridge< Id, Data >, STK::DiagGaussianBridge< Id, Data >, STK::GammaBridge< Id, Data >, STK::HDMatrixGaussianBridge< IdRow, IdCol, Data >, STK::HDGaussianBridge< Id, Data >, STK::KmmBridge< Id, Data >, and STK::PoissonBridge< Id, Data >.
This step can be used by developer to finalize any thing.
It will be called only once after we finish running the estimation algorithm.
Do nothing by default
Reimplemented in STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.
Definition at line 167 of file STK_IMixture.h.
Definition at line 82 of file STK_IMixture.h.
References idData_.
Referenced by STK::CategoricalBridge< Id, Data >::create(), STK::DiagGaussianBridge< Id, Data >::create(), STK::GammaBridge< Id, Data >::create(), STK::HDMatrixGaussianBridge< IdRow, IdCol, Data >::create(), STK::HDGaussianBridge< Id, Data >::create(), STK::KmmBridge< Id, Data >::create(), and STK::PoissonBridge< Id, Data >::create().
This function should be used for Imputation of data.
The default implementation (in the base class) is to do nothing.
Do nothing by default
Reimplemented in STK::KmmBridge< Id, Data >, STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.
Definition at line 140 of file STK_IMixture.h.
This function must be defined in derived class for initialization of the mixture parameters.
This method should create any container needed by the model, resize them and initialize them. Since this method can be used when create is called, its main purpose should be to reset the mixture parameters, while leaving the data unchanged. This function will be called once the model is created and data is set.
Implemented in STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.
This function must be defined to return the posterior probability (PDF) for corresponding sample_num and Cluster_num.
sample_num | Sample number |
Cluster_num | Cluster number |
Implemented in STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.
|
protected |
This function can be used in derived classes to get number of classes.
Definition at line 68 of file STK_IMixture.cpp.
References p_composer_.
Referenced by STK::CategoricalBridge< Id, Data >::create(), STK::DiagGaussianBridge< Id, Data >::create(), STK::GammaBridge< Id, Data >::create(), STK::HDMatrixGaussianBridge< IdRow, IdCol, Data >::create(), STK::HDGaussianBridge< Id, Data >::create(), STK::KmmBridge< Id, Data >::create(), and STK::PoissonBridge< Id, Data >::create().
This function must return the number of free parameters.
Implemented in STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.
This function must return the number of missing value in data set identified by idData_.
Implemented in STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.
|
protected |
This function can be used in derived classes to get number of samples.
Definition at line 64 of file STK_IMixture.cpp.
References p_composer_.
|
inline |
Definition at line 84 of file STK_IMixture.h.
References p_composer_.
Referenced by STK::IMixtureBridge< Derived >::initializeStep(), and setMixtureModel().
This function can be used in derived classes to get estimated number of individuals from the framework.
Definition at line 73 of file STK_IMixture.cpp.
References p_composer_.
This function can be used in derived classes to get posterior probabilities from the framework.
Definition at line 81 of file STK_IMixture.cpp.
References p_composer_.
Referenced by STK::IMixtureBridge< Derived >::paramUpdateStep(), STK::IMixtureBridge< Derived >::randomInit(), and STK::IMixtureBridge< Derived >::writeParameters().
This function can be used in derived classes to get proportions from the framework.
Definition at line 77 of file STK_IMixture.cpp.
References p_composer_.
Referenced by STK::IMixtureBridge< Derived >::paramUpdateStep(), and STK::IMixtureBridge< Derived >::randomInit().
This function can be used in derived classes to get class labels from the framework.
Definition at line 85 of file STK_IMixture.cpp.
References p_composer_.
This function is equivalent to mStep and must be defined to update parameters.
Implemented in STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.
This function should be used in order to initialize randomly the parameters of the mixture.
Implemented in STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.
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.
Do nothing by default
Reimplemented in STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.
Definition at line 157 of file STK_IMixture.h.
This function must be defined for simulation of all the latent variables and/or missing data excluding class labels.
The class labels will be simulated by the framework itself because to do so we have to take into account all the mixture laws.
Do nothing by default
Reimplemented in STK::KmmBridge< Id, Data >, STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.
Definition at line 146 of file STK_IMixture.h.
void STK::IMixture::setMixtureModel | ( | IMixtureStatModel const * | p_composer | ) |
set the mixture composer to the mixture
p_composer | the composer to set |
Definition at line 58 of file STK_IMixture.cpp.
References p_composer(), and p_composer_.
set the parameters of the model.
This function should be used to set the parameters computed using the intermediate results. This method will be called after the long-run and before the finalize step.
Do nothing by default
Reimplemented in STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.
Definition at line 163 of file STK_IMixture.h.
This function should be used to store any intermediate results during various iterations after the burn-in period.
iteration | Provides the iteration number beginning after the burn-in period. |
Do nothing by default
Reimplemented in STK::IMixtureBridge< Derived >, STK::IMixtureBridge< CategoricalBridge< Id, Data > >, STK::IMixtureBridge< DiagGaussianBridge< Id, Data > >, STK::IMixtureBridge< GammaBridge< Id, Data > >, STK::IMixtureBridge< HDGaussianBridge< Id, Data > >, STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >, STK::IMixtureBridge< KmmBridge< Id, Data > >, and STK::IMixtureBridge< PoissonBridge< Id, Data > >.
Definition at line 152 of file STK_IMixture.h.
This function can be used to write summary of parameters on to the output stream.
out | Stream where you want to write the summary of parameters. |
Definition at line 171 of file STK_IMixture.h.
|
private |
|
private |
pointer on the main composer model
Definition at line 207 of file STK_IMixture.h.
Referenced by nbCluster(), nbSample(), p_composer(), p_pk(), p_tik(), p_tk(), p_zi(), and setMixtureModel().