36#ifndef STK_IMIXTUREBRIDGE_H
37#define STK_IMIXTUREBRIDGE_H
71template<
class Derived>
137 template<
class Array>
144 template<
class Array>
146 {
mixture_.param_.setParameters(param.asDerived());}
168 {
return mixture_.lnComponentProbability(
i, k);}
192 {
mixture_.param_.updateStatistics();}
198 {
mixture_.param_.releaseStatistics();}
229 virtual std::vector< std::pair<int,int> >::size_type
findMissing();
255template<
class Derived>
258 , mixture_(nbCluster)
260 , p_dataij_(p_dataij)
265template<
class Derived>
268 , mixture_(
bridge.mixture_)
269 , v_missing_(
bridge.v_missing_)
270 , p_dataij_(
bridge.p_dataij_)
273template<
class Derived>
277 { p_dataij_->elt(
it->first,
it->second) = mixture_.impute(
it->first,
it->second, p_tik()->row(
it->first) );}
280template<
class Derived>
284 { p_dataij_->elt(
it->first,
it->second) = mixture_.sample(
it->first,
it->second, p_tik()->row(
it->first));}
293template<
class Derived>
301template<
class Derived>
304#ifdef STK_MIXTURE_VERBOSE
305 stk_cout <<
_T(
"Entering IMixtureBridge<Derived>::findMissing()\n");
309 for (
int j=p_dataij_->beginCols();
j< p_dataij_->endCols(); ++
j)
311 for (
int i=p_dataij_->beginRows();
i< p_dataij_->endRows(); ++
i)
315 v_missing_.push_back(std::pair<int,int>(
i,
j));
320 return v_missing_.size();
321#ifdef STK_MIXTURE_VERBOSE
322 stk_cout <<
_T(
"IMixtureBridge<Derived>::findMissing() terminated, nbMiss= ") << v_missing_.size() <<
_T(
"\n");
332template<
class Derived>
345 value = this->asDerived().safeValue(
j);
347 p_dataij_->elt(
it->first,
j) = value;
356template<
class Derived>
359 data.resize(v_missing_.size());
360 for(
size_t i = 0;
i< v_missing_.size(); ++
i)
362 data[
i].first = v_missing_[
i];
363 data[
i].second = p_dataij_->elt(v_missing_[
i].first, v_missing_[
i].
second);
In this file we define the data wrapper class.
define the main interface for linking specific mixture model to the composer.
#define STKRUNTIME_ERROR_NO_ARG(Where, Error)
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
Interface base class for the bridges of the STK++ mixture.
void getParameters(Parameters ¶m) const
get the parameters of the model
MissingIndexes::const_iterator ConstIterator
hidden::MixtureBridgeTraits< Derived >::Type Type
virtual int nbMissingValues() const
This function must return the number of missing value in data set identified by idData_.
virtual void samplingStep()
This function must be defined for simulation of all the latent variables and/or missing data excludin...
MissingIndexes v_missing_
vector with the coordinates of the missing values
hidden::MixtureBridgeTraits< Derived >::MissingValues MissingValues
virtual void initializeStep()
Initialize the mixture model before its use by the composer.
IMixtureBridge(Data *p_data, String const &idData, int nbCluster)
default constructor.
virtual void paramUpdateStep()
This function is equivalent to Mstep and must be defined to update parameters.
virtual int nbFreeParameter() const
This function must return the number of free parameters.
Data * p_dataij_
pointer on the data set
hidden::MixtureBridgeTraits< Derived >::MissingIndexes MissingIndexes
hidden::MixtureBridgeTraits< Derived >::Data Data
virtual void removeMissing()
This function will be used once for imputation of missing data at the initialization step (.
virtual void finalizeStep()
This step can be used by developer to finalize any thing.
virtual ~IMixtureBridge()
destructor
void setParameters(Parameters const ¶m)
set the parameters of the model
virtual void releaseIntermediateResults()
This step can be used to signal to the mixtures that they must release the stored results.
virtual void storeIntermediateResults(int iteration)
This function should be used to store any intermediate results during various iterations after the bu...
IMixtureBridge(Mixture const &mixture, String const &idData, int nbCluster)
protected constructor to use in order to create a bridge.
hidden::MixtureBridgeTraits< Derived >::Parameters Parameters
virtual void imputationStep()
This function should be used for imputation of data.
void getParameters(Array ¶m) const
This function is used in order to get the current values of the parameters in an array.
hidden::MixtureBridgeTraits< Derived >::Mixture Mixture
Mixture const & mixture() const
virtual std::vector< std::pair< int, int > >::size_type findMissing()
utility function for lookup the data set and find missing values coordinates.
virtual void writeParameters(ostream &os) const
This function can be used to write summary of parameters to the output stream.
IMixtureBridge(IMixtureBridge const &bridge)
copy constructor
MissingIndexes const & v_missing() const
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...
virtual void randomInit()
This function should be used in order to initialize randomly the parameters of the mixture.
void getMissingValues(MissingValues &data) const
get the (imputed) missing values of a data set.
virtual void setParametersStep()
set the parameters of the model.
Mixture mixture_
The Mixture to bridge with the composer.
Data *const p_dataij() const
virtual Real lnComponentProbability(int i, int k)
This function must be defined to return the component probability distribution function (PDF) for cor...
Interface base class for all the mixture models that will be processed by the composer.
CPointX const * p_tk() const
This function can be used in derived classes to get proportions from the framework.
IMixtureStatModel const *const p_composer() const
CArrayXX const * p_tik() const
This function can be used in derived classes to get posterior probabilities from the framework.
String const & idData() const
int nbCluster() const
This function can be used in derived classes to get number of classes.
Interface base class for all classes implementing the curious recursive template paradigm.
virtual bool finalizeStep()
perform any computation needed after the call of the regression method.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
std::basic_string< Char > String
STK fundamental type of a String.
double Real
STK fundamental type of Real values.
std::basic_ostream< Char > ostream
ostream for Char
The namespace STK is the main domain space of the Statistical ToolKit project.
Arithmetic properties of STK fundamental types.
static Type NA()
Adding a Non Available (NA) special number.
MixtureBridgeTraits struct for bridged mixtures The traits struct MixtureBridgeTraits must be special...