|
STK++ 0.9.13
|
Base class for Learning a Mixture mixed model when some classes are known. More...
#include <STK_MixtureSemiLearner.h>

Public Member Functions | |
| MixtureSemiLearner (int nbSample, int nbCluster) | |
| Constructor. | |
| MixtureSemiLearner (MixtureSemiLearner const &model) | |
| copy constructor. | |
| virtual | ~MixtureSemiLearner () |
| destructor | |
| virtual MixtureSemiLearner * | create () const |
| Create a composer, but reinitialize the mixtures parameters. | |
| virtual MixtureSemiLearner * | clone () const |
| Create a clone of the current model, with mixtures parameters preserved. | |
| std::vector< int > const & | knownLabels () const |
| std::vector< int > const & | unknownLabels () const |
| 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. | |
| template<class RowVector > | |
| void | setLabels (ExprBase< RowVector > const &zi) |
| Set the known labels. | |
Public Member Functions inherited from STK::MixtureComposer | |
| MixtureComposer (int nbSample, int nbCluster) | |
| Constructor. | |
| MixtureComposer (MixtureComposer const &composer) | |
| copy constructor. | |
| virtual | ~MixtureComposer () |
| The registered mixtures will be deleted there. | |
| 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. | |
Public Member Functions inherited from STK::IMixtureComposer | |
| 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 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(). | |
Public Member Functions inherited from STK::IMixtureStatModel | |
| 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) |
Public Member Functions inherited from STK::IStatModelBase | |
| 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 | |
| virtual void | initializeMixtureParameters () |
| Create the mixture model parameters tik_ and pk_. | |
| virtual int | randomTik () |
| generate random tik_ | |
| virtual int | randomZi () |
| generate random zi_ | |
| void | createSemiLearner (MixtureSemiLearner const *const p_learner) |
| Copy the ingredient of the semi-learner in the creation process. | |
Protected Member Functions inherited from STK::MixtureComposer | |
| void | createComposer (std::vector< IMixture * > const &v_mixtures_) |
| Create the composer using existing data handler and mixtures. | |
Protected Member Functions inherited from STK::IMixtureComposer | |
| 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. | |
Protected Member Functions inherited from STK::IMixtureStatModel | |
| IMixtureStatModel (int nbSample, int nbCluster) | |
| Constructor. | |
| IMixtureStatModel (IMixtureStatModel const &model) | |
| copy constructor. | |
| void | setNbCluster (int nbCluster) |
| set the number of cluster of the model | |
Protected Member Functions inherited from STK::IStatModelBase | |
| 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 | |
| std::vector< int > | knownLabels_ |
| indexes of the known labels | |
| std::vector< int > | unknownLabels_ |
| indexes of the unknown labels | |
Protected Attributes inherited from STK::MixtureComposer | |
| Real | meanlnLikelihood_ |
| averaged lnLikelihood values. | |
Protected Attributes inherited from STK::IMixtureStatModel | |
| 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 | |
Additional Inherited Members | |
Public Types inherited from STK::MixtureComposer | |
| typedef std::vector< IMixture * >::const_iterator | ConstMixtIterator |
| typedef std::vector< IMixture * >::iterator | MixtIterator |
Public Types inherited from STK::IMixtureStatModel | |
| typedef std::vector< IMixture * >::const_iterator | ConstMixtIterator |
| typedef std::vector< IMixture * >::iterator | MixtIterator |
Base class for Learning a Mixture mixed model when some classes are known.
This class extend the MixtureComposer class and allow to handle the case where some labels are known (semi-supervised learning).
Definition at line 52 of file STK_MixtureSemiLearner.h.
Constructor.
| nbCluster,nbSample | number of clusters and samples |
Definition at line 48 of file STK_MixtureSemiLearner.cpp.
References unknownLabels_, and STK::IMixtureStatModel::zi_.
| STK::MixtureSemiLearner::MixtureSemiLearner | ( | MixtureSemiLearner const & | model | ) |
copy constructor.
| model | the model to clone |
Definition at line 61 of file STK_MixtureSemiLearner.cpp.
|
virtual |
|
virtual |
Create a clone of the current model, with mixtures parameters preserved.
Reimplemented from STK::MixtureComposer.
Reimplemented in STK::MixtureSemiLearnerFixedProp.
Definition at line 70 of file STK_MixtureSemiLearner.cpp.
|
virtual |
Create a composer, but reinitialize the mixtures parameters.
Reimplemented from STK::MixtureComposer.
Reimplemented in STK::MixtureSemiLearnerFixedProp.
Definition at line 73 of file STK_MixtureSemiLearner.cpp.
References STK::MixtureComposer::createComposer(), createSemiLearner(), STK::IMixtureStatModel::nbCluster(), STK::IStatModelBase::nbSample(), and STK::IMixtureStatModel::v_mixtures().
|
protected |
Copy the ingredient of the semi-learner in the creation process.
Definition at line 178 of file STK_MixtureSemiLearner.cpp.
References knownLabels_, and unknownLabels_.
Referenced by create(), and STK::MixtureSemiLearnerFixedProp::create().
|
virtual |
Replace tik by zik.
Reimplemented from STK::IMixtureComposer.
Definition at line 84 of file STK_MixtureSemiLearner.cpp.
References STK::IMixtureComposer::cStep(), STK::ExprBase< Derived >::minElt(), STK::Stat::sum(), STK::IMixtureStatModel::tik_, STK::IMixtureStatModel::tk_, and unknownLabels_.
Referenced by randomZi(), and sStep().
|
virtual |
compute the zi, the lnLikelihood of the current estimates and the next value of the tik.
Reimplemented from STK::IMixtureComposer.
Definition at line 105 of file STK_MixtureSemiLearner.cpp.
References _T, STK::IMixtureComposer::eStep(), knownLabels_, STK::MixtureComposer::lnComponentProbability(), STK::ExprBase< Derived >::minElt(), STK::IMixtureStatModel::pk_, STK::IStatModelBase::setLnLikelihood(), stk_cout, STK::sum(), STK::Stat::sumByCol(), STK::IMixtureStatModel::tik_, STK::IMixtureStatModel::tk_, unknownLabels_, and STK::IMixtureStatModel::zi_.
|
protectedvirtual |
Create the mixture model parameters tik_ and pk_.
Reimplemented from STK::IMixtureComposer.
Definition at line 140 of file STK_MixtureSemiLearner.cpp.
References knownLabels_, STK::IMixtureStatModel::nbCluster(), STK::ICArray< Derived >::row(), STK::IMixtureStatModel::tik_, unknownLabels_, and STK::IMixtureStatModel::zi_.
Definition at line 70 of file STK_MixtureSemiLearner.h.
References knownLabels_.
|
virtual |
Compute zi using the Map estimate.
Reimplemented from STK::IMixtureComposer.
Definition at line 131 of file STK_MixtureSemiLearner.cpp.
References STK::IMixtureComposer::mapStep(), and unknownLabels_.
|
protectedvirtual |
generate random tik_
Reimplemented from STK::IMixtureComposer.
Definition at line 150 of file STK_MixtureSemiLearner.cpp.
References STK::ExprBase< Derived >::minElt(), STK::IMixtureStatModel::pk_, STK::ICArray< Derived >::row(), STK::IMixtureStatModel::tik_, STK::IMixtureStatModel::tk_, and unknownLabels_.
|
protectedvirtual |
generate random zi_
Reimplemented from STK::IMixtureComposer.
Definition at line 167 of file STK_MixtureSemiLearner.cpp.
References cStep(), STK::IMixtureStatModel::pk_, STK::Law::Categorical::rand(), unknownLabels_, and STK::IMixtureStatModel::zi_.
| void STK::MixtureSemiLearner::setLabels | ( | ExprBase< RowVector > const & | zi | ) |
Set the known labels.
This method is expecting a vector of size nbSample with NA values for unknown labels.
| zi | the vector with the labels |
Definition at line 113 of file STK_MixtureSemiLearner.h.
References _T, STK::baseIdx, STK::ExprBase< Derived >::isNA(), STK::isNA(), knownLabels_, STK::IStatModelBase::nbSample(), STK::ICArray< Derived >::row(), stk_cout, STKRUNTIME_ERROR_NO_ARG, STK::IMixtureStatModel::tik_, unknownLabels_, STK::IMixtureStatModel::zi(), and STK::IMixtureStatModel::zi_.
|
virtual |
Simulate zi accordingly to tik and replace tik by zik by calling cStep().
Reimplemented from STK::IMixtureComposer.
Definition at line 95 of file STK_MixtureSemiLearner.cpp.
References cStep(), STK::IMixtureComposer::sStep(), and unknownLabels_.
Definition at line 72 of file STK_MixtureSemiLearner.h.
References unknownLabels_.
|
protected |
indexes of the known labels
Definition at line 106 of file STK_MixtureSemiLearner.h.
Referenced by createSemiLearner(), eStep(), initializeMixtureParameters(), knownLabels(), and setLabels().
|
protected |
indexes of the unknown labels
Definition at line 108 of file STK_MixtureSemiLearner.h.
Referenced by createSemiLearner(), cStep(), eStep(), initializeMixtureParameters(), mapStep(), MixtureSemiLearner(), randomTik(), randomZi(), setLabels(), sStep(), and unknownLabels().