STK++ 0.9.13
|
Interface base class for the bridges of the STK++ mixture. More...
#include <STK_IMixtureBridge.h>
Public Types | |
enum | { idMixtureClass_ = hidden::MixtureBridgeTraits<Derived>::idMixtureClass_ } |
typedef hidden::MixtureBridgeTraits< Derived >::Mixture | Mixture |
typedef hidden::MixtureBridgeTraits< Derived >::Data | Data |
typedef hidden::MixtureBridgeTraits< Derived >::Type | Type |
typedef hidden::MixtureBridgeTraits< Derived >::Parameters | Parameters |
typedef hidden::MixtureBridgeTraits< Derived >::MissingIndexes | MissingIndexes |
typedef hidden::MixtureBridgeTraits< Derived >::MissingValues | MissingValues |
typedef MissingIndexes::const_iterator | ConstIterator |
Public Member Functions | |
Mixture const & | mixture () const |
MissingIndexes const & | v_missing () const |
Data *const | p_dataij () const |
int | nbMissing () const |
void | getMissingValues (MissingValues &data) const |
get the (imputed) missing values of a data set. | |
void | getParameters (Parameters ¶m) const |
get the parameters of the model | |
void | setParameters (Parameters const ¶m) |
set the parameters of the model | |
template<class Array > | |
void | getParameters (Array ¶m) const |
This function is used in order to get the current values of the parameters in an array. | |
template<class Array > | |
void | setParameters (ExprBase< Array > const ¶m) |
This function is used in order to set the current values of the parameters to the parameters using an array. | |
virtual void | initializeStep () |
Initialize the mixture model before its use by the composer. | |
virtual Real | lnComponentProbability (int i, int k) |
This function must be defined to return the component probability distribution function (PDF) for corresponding sample i and cluster k. | |
virtual void | paramUpdateStep () |
This function is equivalent to Mstep and must be defined to update parameters. | |
virtual void | randomInit () |
This function should be used in order to initialize randomly the parameters of the mixture. | |
virtual int | nbFreeParameter () const |
This function must return the number of free parameters. | |
virtual int | nbMissingValues () const |
This function must return the number of missing value in data set identified by idData_. | |
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 | 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 | writeParameters (ostream &os) const |
This function can be used to write summary of parameters to the output stream. | |
![]() | |
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 | writeParameters (std::ostream &out) const |
This function can be used to write summary of parameters on to the output stream. | |
![]() | |
Derived & | asDerived () |
static cast : return a reference of this with a cast to the derived class. | |
Derived const & | asDerived () const |
static cast : return a const reference of this with a cast to the derived class. | |
Derived * | asPtrDerived () |
static cast : return a ptr on a Derived of this with a cast to the derived class. | |
Derived const * | asPtrDerived () const |
static cast : return a ptr on a constant Derived of this with a cast to the derived class. | |
Derived * | clone () const |
create a leaf using the copy constructor of the Derived class. | |
Derived * | clone (bool isRef) const |
create a leaf using the copy constructor of the Derived class and a flag determining if the clone is a reference or not. | |
Protected Member Functions | |
IMixtureBridge (Data *p_data, String const &idData, int nbCluster) | |
default constructor. | |
IMixtureBridge (IMixtureBridge const &bridge) | |
copy constructor | |
IMixtureBridge (Mixture const &mixture, String const &idData, int nbCluster) | |
protected constructor to use in order to create a bridge. | |
virtual | ~IMixtureBridge () |
destructor | |
virtual std::vector< std::pair< int, int > >::size_type | findMissing () |
utility function for lookup the data set and find missing values coordinates. | |
virtual void | removeMissing () |
This function will be used once for imputation of missing data at the initialization step (. | |
![]() | |
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. | |
![]() | |
IRecursiveTemplate () | |
constructor. | |
~IRecursiveTemplate () | |
destructor. | |
Protected Attributes | |
Mixture | mixture_ |
The Mixture to bridge with the composer. | |
MissingIndexes | v_missing_ |
vector with the coordinates of the missing values | |
Data * | p_dataij_ |
pointer on the data set | |
Interface base class for the bridges of the STK++ mixture.
This interface produce a default implementation to all the virtual functions required by the STK::IMixture interface by delegating to the derived bridged Mixture the computations.
The virtual methods to implement in derived class are
Pseudo virtual method to implement in derived class are
The members of this interface are the following
Definition at line 72 of file STK_IMixtureBridge.h.
typedef MissingIndexes::const_iterator STK::IMixtureBridge< Derived >::ConstIterator |
Definition at line 81 of file STK_IMixtureBridge.h.
typedef hidden::MixtureBridgeTraits<Derived>::Data STK::IMixtureBridge< Derived >::Data |
Definition at line 76 of file STK_IMixtureBridge.h.
typedef hidden::MixtureBridgeTraits<Derived>::MissingIndexes STK::IMixtureBridge< Derived >::MissingIndexes |
Definition at line 79 of file STK_IMixtureBridge.h.
typedef hidden::MixtureBridgeTraits<Derived>::MissingValues STK::IMixtureBridge< Derived >::MissingValues |
Definition at line 80 of file STK_IMixtureBridge.h.
typedef hidden::MixtureBridgeTraits<Derived>::Mixture STK::IMixtureBridge< Derived >::Mixture |
Definition at line 75 of file STK_IMixtureBridge.h.
typedef hidden::MixtureBridgeTraits<Derived>::Parameters STK::IMixtureBridge< Derived >::Parameters |
Definition at line 78 of file STK_IMixtureBridge.h.
typedef hidden::MixtureBridgeTraits<Derived>::Type STK::IMixtureBridge< Derived >::Type |
Definition at line 77 of file STK_IMixtureBridge.h.
Enumerator | |
---|---|
idMixtureClass_ |
Definition at line 83 of file STK_IMixtureBridge.h.
|
protected |
default constructor.
p_data | pointer on the DataBridge wrapping the data set |
idData | id name of the data |
nbCluster | number of cluster |
Definition at line 256 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::findMissing().
|
protected |
copy constructor
bridge | the IMixtureBridge to copy |
Definition at line 266 of file STK_IMixtureBridge.h.
|
protected |
protected constructor to use in order to create a bridge.
mixture | the mixture to copy |
idData | id name of the mixture |
nbCluster | number of cluster |
Definition at line 294 of file STK_IMixtureBridge.h.
|
inlineprotectedvirtual |
|
inlinevirtual |
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::IMixture.
Definition at line 208 of file STK_IMixtureBridge.h.
References STK::IRegression< YArray, XArray, Weights >::finalizeStep(), and STK::IMixtureBridge< Derived >::mixture_.
|
protectedvirtual |
utility function for lookup the data set and find missing values coordinates.
Definition at line 302 of file STK_IMixtureBridge.h.
Referenced by STK::IMixtureBridge< Derived >::IMixtureBridge().
void STK::IMixtureBridge< Derived >::getMissingValues | ( | MissingValues & | data | ) | const |
get the (imputed) missing values of a data set.
data | the array to return with the missing values |
Definition at line 357 of file STK_IMixtureBridge.h.
|
inline |
This function is used in order to get the current values of the parameters in an array.
param | array that will store the parameters of the mixture. |
Definition at line 138 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::mixture_.
|
inline |
get the parameters of the model
Definition at line 128 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::mixture_.
|
inlinevirtual |
This function should be used for imputation of data.
The default implementation (in base class IMixture) is to do nothing.
Reimplemented from STK::IMixture.
Reimplemented in STK::KmmBridge< Id, Data >.
Definition at line 274 of file STK_IMixtureBridge.h.
|
inlinevirtual |
Initialize the mixture model before its use by the composer.
The parameters values are set to their default values if the mixture_ is newly created. if IMixtureBridge::initializeStep is used during a cloning, mixture class have to take care of the existing values of the parameters.
Implements STK::IMixture.
Definition at line 156 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::initializeStep(), STK::Clust::initializeStepFail_, STK::IMixtureBridge< Derived >::mixture_, STK::IMixture::p_composer(), and STKRUNTIME_ERROR_NO_ARG.
Referenced by STK::IMixtureBridge< Derived >::initializeStep().
|
inlinevirtual |
This function must be defined to return the component probability distribution function (PDF) for corresponding sample i and cluster k.
i,k | sample and cluster numbers |
Implements STK::IMixture.
Definition at line 167 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::mixture_.
|
inline |
Definition at line 113 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::mixture_.
|
inlinevirtual |
This function must return the number of free parameters.
Implements STK::IMixture.
Definition at line 181 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::mixture_.
|
inline |
Definition at line 119 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::v_missing_.
|
inlinevirtual |
This function must return the number of missing value in data set identified by idData_.
Implements STK::IMixture.
Definition at line 185 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::v_missing_.
|
inline |
Definition at line 117 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::p_dataij_.
|
inlinevirtual |
This function is equivalent to Mstep and must be defined to update parameters.
Implements STK::IMixture.
Definition at line 172 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::mixture_, STK::Clust::mStepFail_, STK::IMixture::p_tik(), and STK::IMixture::p_tk().
|
inlinevirtual |
This function should be used in order to initialize randomly the parameters of the mixture.
Implements STK::IMixture.
Definition at line 177 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::mixture_, STK::IMixture::p_tik(), and STK::IMixture::p_tk().
|
inlinevirtual |
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::IMixture.
Definition at line 197 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::mixture_.
|
protectedvirtual |
This function will be used once for imputation of missing data at the initialization step (.
By default missing values in a column will be replaced by the mean or map (maximum a posteriori) value of the column. Derived class as to implement the safeValue(i,j) method.
Definition at line 333 of file STK_IMixtureBridge.h.
References STK::Arithmetic< Type >::NA().
|
inlinevirtual |
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.
Reimplemented from STK::IMixture.
Reimplemented in STK::KmmBridge< Id, Data >.
Definition at line 281 of file STK_IMixtureBridge.h.
|
inline |
This function is used in order to set the current values of the parameters to the parameters using an array.
param | the array/expression with the parameters of the mixture to store in the Parameters. |
Definition at line 145 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::mixture_.
|
inline |
set the parameters of the model
Definition at line 130 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::mixture_.
|
inlinevirtual |
set the parameters of the model.
This step should be used to set the initialize the statistics to the current value of the parameters.
Reimplemented from STK::IMixture.
Definition at line 203 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::mixture_.
|
inlinevirtual |
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. |
Reimplemented from STK::IMixture.
Definition at line 191 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::mixture_.
|
inline |
Definition at line 115 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::v_missing_.
|
inlinevirtual |
This function can be used to write summary of parameters to the output stream.
os | Stream where you want to write the summary of parameters. |
Definition at line 222 of file STK_IMixtureBridge.h.
References STK::IMixtureBridge< Derived >::mixture_, and STK::IMixture::p_tik().
|
protected |
The Mixture to bridge with the composer.
Definition at line 243 of file STK_IMixtureBridge.h.
Referenced by STK::IMixtureBridge< Derived >::finalizeStep(), STK::IMixtureBridge< Derived >::getParameters(), STK::IMixtureBridge< Derived >::getParameters(), STK::IMixtureBridge< Derived >::initializeStep(), STK::IMixtureBridge< Derived >::lnComponentProbability(), STK::IMixtureBridge< Derived >::mixture(), STK::IMixtureBridge< Derived >::nbFreeParameter(), STK::IMixtureBridge< Derived >::paramUpdateStep(), STK::IMixtureBridge< Derived >::randomInit(), STK::IMixtureBridge< Derived >::releaseIntermediateResults(), STK::IMixtureBridge< Derived >::setParameters(), STK::IMixtureBridge< Derived >::setParameters(), STK::IMixtureBridge< Derived >::setParametersStep(), STK::IMixtureBridge< Derived >::storeIntermediateResults(), and STK::IMixtureBridge< Derived >::writeParameters().
|
protected |
pointer on the data set
Definition at line 247 of file STK_IMixtureBridge.h.
Referenced by STK::CategoricalBridge< Id, Data >::create(), STK::DiagGaussianBridge< Id, Data >::create(), STK::GammaBridge< Id, Data >::create(), STK::HDMatrixGaussianBridge< IdRow, IdCol, Data >::create(), and STK::IMixtureBridge< Derived >::p_dataij().
|
protected |
vector with the coordinates of the missing values
Definition at line 245 of file STK_IMixtureBridge.h.
Referenced by STK::IMixtureBridge< Derived >::nbMissing(), STK::IMixtureBridge< Derived >::nbMissingValues(), and STK::IMixtureBridge< Derived >::v_missing().