STK++ 0.9.13
STK::HDMatrixGaussianBridge< IdRow, IdCol, Data > Class Template Reference

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

#include <STK_HDMatrixGaussianBridge.h>

Inheritance diagram for STK::HDMatrixGaussianBridge< IdRow, IdCol, Data >:
Inheritance graph

Public Types

enum  { idMixtureClass_ = Clust::HDMatrixGaussian_ }
 
typedef IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > > Base
 
typedef hidden::MixtureBridgeTraits< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::Mixture Mixture
 
typedef hidden::MixtureBridgeTraits< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::Parameters Parameters
 
typedef hidden::MixtureBridgeTraits< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::Type Type
 
typedef std::vector< std::pair< int, int > >::const_iterator ConstIterator
 
- Public Types inherited from STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >
enum  
 
typedef hidden::MixtureBridgeTraits< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::Mixture Mixture
 
typedef hidden::MixtureBridgeTraits< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::Data Data
 
typedef hidden::MixtureBridgeTraits< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::Type Type
 
typedef hidden::MixtureBridgeTraits< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::Parameters Parameters
 
typedef hidden::MixtureBridgeTraits< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::MissingIndexes MissingIndexes
 
typedef hidden::MixtureBridgeTraits< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::MissingValues MissingValues
 
typedef MissingIndexes::const_iterator ConstIterator
 

Public Member Functions

 HDMatrixGaussianBridge (Data *p_dataij, String const &idData, int nbRow, int nbCluster)
 default constructor.
 
 HDMatrixGaussianBridge (HDMatrixGaussianBridge const &bridge)
 copy constructor
 
virtual ~HDMatrixGaussianBridge ()
 destructor
 
virtual HDMatrixGaussianBridgeclone () const
 This is a standard clone function in usual sense.
 
virtual HDMatrixGaussianBridgecreate () const
 This is a standard create function in usual sense.
 
Type safeValue (int j) const
 
- Public Member Functions inherited from STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, 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 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.
 
- 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

 HDMatrixGaussianBridge (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< HDMatrixGaussianBridge< IdRow, IdCol, 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< HDMatrixGaussianBridge< IdRow, IdCol, 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 IdRow, int IdCol, class Data>
class STK::HDMatrixGaussianBridge< IdRow, IdCol, Data >

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

This class inherit from the interface IMixture and delegate almost all the treatments to the wrapped class. The bridge handles the missing values and the averaging of the parameters and imputed/simulated missing values during the estimation process.

Template Parameters
Idis any identifier of a concrete model deriving from the interface STK::IMixtureDensity class. This identifier should be find in the Clust::Mixture enum.
Datacontainer of the data used by the STK::DataBridge class

Definition at line 94 of file STK_HDMatrixGaussianBridge.h.

Member Typedef Documentation

◆ Base

◆ ConstIterator

template<int IdRow, int IdCol, class Data >
typedef std::vector<std::pair<int,int>>::const_iterator STK::HDMatrixGaussianBridge< IdRow, IdCol, Data >::ConstIterator

Definition at line 109 of file STK_HDMatrixGaussianBridge.h.

◆ Mixture

◆ Parameters

◆ Type

Member Enumeration Documentation

◆ anonymous enum

template<int IdRow, int IdCol, class Data >
anonymous enum
Enumerator
idMixtureClass_ 

Definition at line 105 of file STK_HDMatrixGaussianBridge.h.

Constructor & Destructor Documentation

◆ HDMatrixGaussianBridge() [1/3]

template<int IdRow, int IdCol, class Data >
STK::HDMatrixGaussianBridge< IdRow, IdCol, Data >::HDMatrixGaussianBridge ( Data p_dataij,
String const idData,
int  nbRow,
int  nbCluster 
)
inline

default constructor.

Remove the missing values from the data set and initialize the mixture by setting the data set.

Parameters
p_dataijpointer on the data set used by the bridge.
idDataid name of the mixture model
nbClusternumber of cluster

Definition at line 122 of file STK_HDMatrixGaussianBridge.h.

127 {
128 removeMissing(); // remove missing from data only once at creation
129 mixture_.setData(p_data_->dataij());
130 }
IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > > Base
virtual void removeMissing()
This function will be used once for imputation of missing data at the initialization step (.
String const & idData() const
int nbCluster() const
This function can be used in derived classes to get number of classes.

References STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::mixture_, and STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::removeMissing().

◆ HDMatrixGaussianBridge() [2/3]

template<int IdRow, int IdCol, class Data >
STK::HDMatrixGaussianBridge< IdRow, IdCol, Data >::HDMatrixGaussianBridge ( HDMatrixGaussianBridge< IdRow, IdCol, Data > const bridge)
inline

copy constructor

Definition at line 132 of file STK_HDMatrixGaussianBridge.h.

132: Base(bridge) {}

◆ ~HDMatrixGaussianBridge()

template<int IdRow, int IdCol, class Data >
virtual STK::HDMatrixGaussianBridge< IdRow, IdCol, Data >::~HDMatrixGaussianBridge ( )
inlinevirtual

destructor

Definition at line 134 of file STK_HDMatrixGaussianBridge.h.

134{}

◆ HDMatrixGaussianBridge() [3/3]

template<int IdRow, int IdCol, class Data >
STK::HDMatrixGaussianBridge< IdRow, IdCol, Data >::HDMatrixGaussianBridge ( 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 166 of file STK_HDMatrixGaussianBridge.h.

Member Function Documentation

◆ clone()

template<int IdRow, int IdCol, class Data >
virtual HDMatrixGaussianBridge * STK::HDMatrixGaussianBridge< IdRow, IdCol, 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 141 of file STK_HDMatrixGaussianBridge.h.

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

◆ create()

template<int IdRow, int IdCol, class Data >
virtual HDMatrixGaussianBridge * STK::HDMatrixGaussianBridge< IdRow, IdCol, 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 147 of file STK_HDMatrixGaussianBridge.h.

148 {
149 HDMatrixGaussianBridge* p_bridge = new HDMatrixGaussianBridge( mixture_, this->idData(), this->nbCluster());
150 p_bridge->p_dataij_ = p_dataij_;
151 p_bridge->mixture_.setData(*p_dataij_);
152 p_bridge->v_missing_ = v_missing_;
153 return p_bridge;
154 }
MissingIndexes v_missing_
vector with the coordinates of the missing values

References STK::IMixture::idData(), STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::mixture_, STK::IMixture::nbCluster(), STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::p_dataij_, STK::IMixtureBridge< Derived >::p_dataij_, STK::IRunnerSupervised< YArray_, XArray_, Weights_ >::setData(), and STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::v_missing_.

◆ safeValue()

template<int IdRow, int IdCol, class Data >
Type STK::HDMatrixGaussianBridge< IdRow, IdCol, 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 157 of file STK_HDMatrixGaussianBridge.h.

158 { return p_dataij_->col(j).meanSafe();}

References STK::IMixtureBridge< HDMatrixGaussianBridge< IdRow, IdCol, Data > >::p_dataij_.


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