STK++ 0.9.13
STK::KmmBridge< Id, Data > Class Template Reference

template implementation of the IMixture interface allowing to bridge a STK++ kernel mixture with the composer. More...

#include <STK_KmmBridge.h>

Inheritance diagram for STK::KmmBridge< Id, Data >:
Inheritance graph

Public Types

typedef IMixtureBridge< KmmBridge< Id, Data > > Base
 
typedef hidden::MixtureBridgeTraits< KmmBridge< Id, Data > >::Mixture Mixture
 
typedef hidden::MixtureBridgeTraits< KmmBridge< Id, Data > >::Parameters Parameters
 
typedef Data::Type Type
 
- Public Types inherited from STK::IMixtureBridge< KmmBridge< Id, Data > >
enum  
 
typedef hidden::MixtureBridgeTraits< KmmBridge< Id, Data > >::Mixture Mixture
 
typedef hidden::MixtureBridgeTraits< KmmBridge< Id, Data > >::Data Data
 
typedef hidden::MixtureBridgeTraits< KmmBridge< Id, Data > >::Type Type
 
typedef hidden::MixtureBridgeTraits< KmmBridge< Id, Data > >::Parameters Parameters
 
typedef hidden::MixtureBridgeTraits< KmmBridge< Id, Data > >::MissingIndexes MissingIndexes
 
typedef hidden::MixtureBridgeTraits< KmmBridge< Id, Data > >::MissingValues MissingValues
 
typedef MissingIndexes::const_iterator ConstIterator
 

Public Member Functions

 KmmBridge (Data *p_dataij, String const &idData, int nbCluster)
 default constructor.
 
 KmmBridge (KmmBridge const &bridge)
 copy constructor
 
virtual ~KmmBridge ()
 destructor
 
virtual KmmBridgeclone () const
 This is a standard clone function in usual sense.
 
virtual KmmBridgecreate () const
 This is a standard create function in usual sense.
 
void setDim (Real const &dim)
 set the dimension of the kernel mixture model
 
template<class Vector >
void setDim (ExprBase< Vector > const &dim)
 set the dimension of the kernel mixture model using row vector
 
void setKernel (Kernel::IKernel const *p_kernel)
 set the kernel
 
virtual void imputationStep ()
 do nothing for kernel mixture models
 
virtual void samplingStep ()
 do nothing for kernel mixture models
 
Type safeValue (int j) const
 
- Public Member Functions inherited from STK::IMixtureBridge< KmmBridge< Id, Data > >
Mixture constmixture () const
 
MissingIndexes constv_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 &param) const
 get the parameters of the model
 
void getParameters (Array &param) const
 This function is used in order to get the current values of the parameters in an array.
 
void setParameters (Parameters const &param)
 set the parameters of the model
 
void setParameters (ExprBase< Array > const &param)
 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 writeParameters (ostream &os) const
 This function can be used to write summary of parameters to the output stream.
 
- Public Member Functions inherited from STK::IMixture
 IMixture (String const &idData=String())
 Constructor with identification character.
 
 IMixture (IMixture const &mixture)
 copy constructor.
 
virtual ~IMixture ()
 Virtual destructor.
 
String constidData () const
 
IMixtureStatModel const *const p_composer () const
 
void setMixtureModel (IMixtureStatModel const *p_composer)
 set the mixture composer to the mixture
 
virtual void writeParameters (std::ostream &out) const
 This function can be used to write summary of parameters on to the output stream.
 
- Public Member Functions inherited from STK::IRecursiveTemplate< Derived >
Derived & asDerived ()
 static cast : return a reference of this with a cast to the derived class.
 
Derived constasDerived () 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 constasPtrDerived () 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.
 

Private Member Functions

void initializeBridge ()
 This function will be used in order to initialize the mixture model using informations stored by the DataBridge.
 
 KmmBridge (Mixture const &mixture, String const &idData, int nbCluster)
 protected constructor to use in order to create a bridge.
 

Additional Inherited Members

- Protected Member Functions inherited from STK::IMixtureBridge< KmmBridge< Id, Data > >
 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 (.
 
- Protected Member Functions inherited from STK::IMixture
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 constp_pk () const
 This function can be used in derived classes to get estimated number of individuals from the framework.
 
CPointX constp_tk () const
 This function can be used in derived classes to get proportions from the framework.
 
CArrayXX constp_tik () const
 This function can be used in derived classes to get posterior probabilities from the framework.
 
CVectorXi constp_zi () const
 This function can be used in derived classes to get class labels from the framework.
 
- Protected Member Functions inherited from STK::IRecursiveTemplate< Derived >
 IRecursiveTemplate ()
 constructor.
 
 ~IRecursiveTemplate ()
 destructor.
 
- Protected Attributes inherited from STK::IMixtureBridge< KmmBridge< Id, Data > >
Mixture mixture_
 The Mixture to bridge with the composer.
 
MissingIndexes v_missing_
 vector with the coordinates of the missing values
 
Datap_dataij_
 pointer on the data set
 

Detailed Description

template<int Id, class Data>
class STK::KmmBridge< Id, Data >

template implementation of the IMixture interface allowing to bridge a STK++ kernel mixture with the composer.

This class inherit from the interface IMixtureBridge.

Note
The p_data_ DataManager is wrapping the Gram matrix.
Template Parameters
Idis any identifier of a concrete model deriving from the interface STK::IMixtureDensity class.
Datais any container storing the data.

Definition at line 117 of file STK_KmmBridge.h.

Member Typedef Documentation

◆ Base

Definition at line 120 of file STK_KmmBridge.h.

◆ Mixture

Definition at line 121 of file STK_KmmBridge.h.

◆ Parameters

template<int Id, class Data >
typedef hidden::MixtureBridgeTraits<KmmBridge<Id,Data>>::Parameters STK::KmmBridge< Id, Data >::Parameters

Definition at line 122 of file STK_KmmBridge.h.

◆ Type

template<int Id, class Data >
typedef Data::Type STK::KmmBridge< Id, Data >::Type

Definition at line 123 of file STK_KmmBridge.h.

Constructor & Destructor Documentation

◆ KmmBridge() [1/3]

template<int Id, class Data >
STK::KmmBridge< Id, Data >::KmmBridge ( Data p_dataij,
String const idData,
int  nbCluster 
)
inline

default constructor.

Parameters
p_dataijpointer on the data set (should be zero, never used)
idDataid name of the mixture model
nbClusternumber of cluster

Definition at line 135 of file STK_KmmBridge.h.

137 { initializeBridge();}
String const & idData() const
int nbCluster() const
This function can be used in derived classes to get number of classes.
IMixtureBridge< KmmBridge< Id, Data > > Base
void initializeBridge()
This function will be used in order to initialize the mixture model using informations stored by the ...

References STK::KmmBridge< Id, Data >::initializeBridge().

◆ KmmBridge() [2/3]

template<int Id, class Data >
STK::KmmBridge< Id, Data >::KmmBridge ( KmmBridge< Id, Data > const bridge)
inline

copy constructor

Definition at line 139 of file STK_KmmBridge.h.

139: Base(bridge) { initializeBridge();}

References STK::KmmBridge< Id, Data >::initializeBridge().

◆ ~KmmBridge()

template<int Id, class Data >
virtual STK::KmmBridge< Id, Data >::~KmmBridge ( )
inlinevirtual

destructor

Definition at line 141 of file STK_KmmBridge.h.

141{}

◆ KmmBridge() [3/3]

template<int Id, class Data >
STK::KmmBridge< Id, Data >::KmmBridge ( Mixture const mixture,
String const idData,
int  nbCluster 
)
inlineprivate

protected constructor to use in order to create a bridge.

Parameters
mixturethe mixture to copy
idDataid name of the mixture
nbClusternumber of cluster

Definition at line 196 of file STK_KmmBridge.h.

Member Function Documentation

◆ clone()

template<int Id, class Data >
virtual KmmBridge * STK::KmmBridge< Id, Data >::clone ( ) const
inlinevirtual

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.

Returns
New instance of class as that of calling object.

Implements STK::IMixture.

Definition at line 148 of file STK_KmmBridge.h.

148{ return new KmmBridge(*this);}
KmmBridge(Data *p_dataij, String const &idData, int nbCluster)
default constructor.

◆ create()

template<int Id, class Data >
virtual KmmBridge * STK::KmmBridge< Id, Data >::create ( ) const
inlinevirtual

This is a standard create function in usual sense.

It must be defined to provide new object of your class with correct dimensions and state. In other words, this is equivalent to virtual constructor.

Returns
New instance of class as that of calling object.

Implements STK::IMixture.

Definition at line 154 of file STK_KmmBridge.h.

155 {
156 KmmBridge* p_bridge = new KmmBridge( mixture_, this->idData(), this->nbCluster());
157 p_bridge->setDim(mixture_.param().dim_);
158 p_bridge->setKernel(mixture_.p_kernel());
159 return p_bridge;
160 }
Mixture mixture_
The Mixture to bridge with the composer.

References STK::IMixture::idData(), STK::IMixtureBridge< KmmBridge< Id, Data > >::mixture_, STK::IMixture::nbCluster(), and STK::KmmBridge< Id, Data >::setDim().

◆ imputationStep()

template<int Id, class Data >
virtual void STK::KmmBridge< Id, Data >::imputationStep ( )
inlinevirtual

do nothing for kernel mixture models

Reimplemented from STK::IMixtureBridge< KmmBridge< Id, Data > >.

Definition at line 174 of file STK_KmmBridge.h.

174{}

◆ initializeBridge()

template<int Id, class Data >
void STK::KmmBridge< Id, Data >::initializeBridge ( )
inlineprivate

This function will be used in order to initialize the mixture model using informations stored by the DataBridge.

In the kernel bridge the mixture use the intermediary array dik_ computed by the bridge. The initialization step consist in resizing the array and to set the pointer to mixture_.

Definition at line 190 of file STK_KmmBridge.h.

190{}

Referenced by STK::KmmBridge< Id, Data >::KmmBridge(), and STK::KmmBridge< Id, Data >::KmmBridge().

◆ safeValue()

template<int Id, class Data >
Type STK::KmmBridge< Id, Data >::safeValue ( int  j) const
inline
Returns
a safe value for the jth variable
Parameters
jindex of the column with the safe value needed

Definition at line 180 of file STK_KmmBridge.h.

180{ return Type();}
Data::Type Type

◆ samplingStep()

template<int Id, class Data >
virtual void STK::KmmBridge< Id, Data >::samplingStep ( )
inlinevirtual

do nothing for kernel mixture models

Reimplemented from STK::IMixtureBridge< KmmBridge< Id, Data > >.

Definition at line 176 of file STK_KmmBridge.h.

176{}

◆ setDim() [1/2]

template<int Id, class Data >
template<class Vector >
void STK::KmmBridge< Id, Data >::setDim ( ExprBase< Vector > const dim)
inline

set the dimension of the kernel mixture model using row vector

Definition at line 165 of file STK_KmmBridge.h.

166 {
168 mixture_.setDim(dim.asDerived());
169 }
#define STK_STATIC_ASSERT_ONE_DIMENSION_ONLY(EXPR)
Array2DVector< Real > Vector
final class for a Real vertical container.

References STK::IMixtureBridge< KmmBridge< Id, Data > >::mixture_, and STK_STATIC_ASSERT_ONE_DIMENSION_ONLY.

◆ setDim() [2/2]

template<int Id, class Data >
void STK::KmmBridge< Id, Data >::setDim ( Real const dim)
inline

set the dimension of the kernel mixture model

Definition at line 162 of file STK_KmmBridge.h.

162{ mixture_.setDim(dim);}

References STK::IMixtureBridge< KmmBridge< Id, Data > >::mixture_.

Referenced by STK::KmmBridge< Id, Data >::create().

◆ setKernel()

template<int Id, class Data >
void STK::KmmBridge< Id, Data >::setKernel ( Kernel::IKernel const p_kernel)
inline

set the kernel

Definition at line 171 of file STK_KmmBridge.h.

171{ mixture_.setKernel(p_kernel);}

References STK::IMixtureBridge< KmmBridge< Id, Data > >::mixture_.


The documentation for this class was generated from the following file: