STK++ 0.9.13
STK::SemiSEMPredict Class Reference

Implementation of the SemiSEMPredict algorithm. More...

#include <STK_MixtureAlgoPredict.h>

Inheritance diagram for STK::SemiSEMPredict:
Inheritance graph

Public Member Functions

 SemiSEMPredict ()
 default constructor
 
 SemiSEMPredict (SemiSEMPredict const &algo)
 Copy constructor.
 
virtual ~SemiSEMPredict ()
 destructor
 
virtual SemiSEMPredictclone () const
 clone pattern
 
virtual bool run ()
 run the algorithm on the model until the maximal number of iteration is reached.
 
- Public Member Functions inherited from STK::IMixtureAlgoPredict
virtual ~IMixtureAlgoPredict ()
 destructor
 
int nbIterBurn () const
 
int setNbIterLong () const
 
int epsilon () const
 
void setModel (IMixtureComposer *p_model)
 set model
 
void setNbIterBurn (int nbIterBurn)
 set number of burning iterations
 
void setNbIterLong (int nbIterLong)
 set number of long iterations
 
void setEpsilon (Real epsilon)
 set tolerance value
 
- Public Member Functions inherited from STK::IRunnerBase
String consterror () const
 get the last error message.
 

Additional Inherited Members

- Protected Member Functions inherited from STK::IMixtureAlgoPredict
 IMixtureAlgoPredict ()
 default constructor
 
 IMixtureAlgoPredict (IMixtureAlgoPredict const &algo)
 Copy constructor.
 
bool predictBayesClassifier ()
 predict class labels when there is no missing values.
 
bool burnStep ()
 Perform burn step using SEM algorithm.
 
- Protected Member Functions inherited from STK::IRunnerBase
 IRunnerBase ()
 default constructor
 
 IRunnerBase (IRunnerBase const &runner)
 copy constructor
 
virtual ~IRunnerBase ()
 destructor
 
virtual void update ()
 update the runner.
 
- Protected Attributes inherited from STK::IMixtureAlgoPredict
IMixtureComposerp_model_
 pointer on the mixture model
 
int nbIterBurn_
 Number of burning iterations of the algorithm.
 
int nbIterLong_
 maximal number of iterations of the algorithm
 
Real epsilon_
 tolerance of the algorithm.
 
- Protected Attributes inherited from STK::IRunnerBase
String msg_error_
 String with the last error message.
 
bool hasRun_
 true if run has been used, false otherwise
 

Detailed Description

Implementation of the SemiSEMPredict algorithm.

SemiSEMPredict algorithm starts calling an initializationStep and then calls until the number of iteration is reached steps:

  • samplingStep()
  • eStep()
  • storeIntermediateResults(iter). It ends by a call to setParameterStep(). This is the counterpart of SemiSEMSAlgo for prediction.

Definition at line 81 of file STK_MixtureAlgoPredict.h.

Constructor & Destructor Documentation

◆ SemiSEMPredict() [1/2]

STK::SemiSEMPredict::SemiSEMPredict ( )
inline

default constructor

Definition at line 85 of file STK_MixtureAlgoPredict.h.

IMixtureAlgoPredict()
default constructor

Referenced by clone().

◆ SemiSEMPredict() [2/2]

STK::SemiSEMPredict::SemiSEMPredict ( SemiSEMPredict const algo)
inline

Copy constructor.

Parameters
algothe algorithm to copy

Definition at line 88 of file STK_MixtureAlgoPredict.h.

88: IMixtureAlgoPredict(algo) {}

◆ ~SemiSEMPredict()

virtual STK::SemiSEMPredict::~SemiSEMPredict ( )
inlinevirtual

destructor

Definition at line 90 of file STK_MixtureAlgoPredict.h.

90{}

Member Function Documentation

◆ clone()

virtual SemiSEMPredict * STK::SemiSEMPredict::clone ( ) const
inlinevirtual

clone pattern

Definition at line 92 of file STK_MixtureAlgoPredict.h.

92{ return new SemiSEMPredict(*this);}
SemiSEMPredict()
default constructor

References SemiSEMPredict().

◆ run()

bool STK::SemiSEMPredict::run ( )
virtual

run the algorithm on the model until the maximal number of iteration is reached.

Returns
true if no error occur, false otherwise.

Implements STK::IRunnerBase.

Definition at line 114 of file STK_MixtureAlgoPredict.cpp.

115{
117 { return predictBayesClassifier();}
118
119#ifdef STK_MIXTURE_VERY_VERBOSE
120 stk_cout << _T("------------------------------------\n");
121 stk_cout << _T("Entering SemiSEMPredict::run() with:\n");
122 stk_cout << _T("nbIterBurn_ = ") << nbIterBurn_ << _T("\n")
123 << _T("nbIterLong_ = ") << nbIterLong_
124 << _T("p_model_->lnLikelihood = ") << p_model_->lnLikelihood() << _T("\n");
125#endif
126 try
127 {
129 if (!burnStep())
130 {
131 p_model_->mapStep();
133 return false;
134 }
135 int iter;
136 for (iter = 0; iter < nbIterLong_; ++iter)
137 {
139 p_model_->eStep();
140 p_model_->storeIntermediateResults(iter+1); // store current parameters
141 }
142 }
143 catch (Clust::exceptions const& error)
144 {
146#ifdef STK_MIXTURE_VERBOSE
147 stk_cout << _T("An exception occur in SemiSEMPredict::run(): ") << msg_error_ << _T("\n");
148#endif
150 p_model_->mapStep();
152 return false;
153 }
154 catch (Exception const& error)
155 {
157#ifdef STK_MIXTURE_VERBOSE
158 stk_cout << _T("An error occur in SemiSEMPredict::run():\n") << msg_error_ << _T("\n");
159#endif
161 p_model_->mapStep();
163 return false;
164 }
165#ifdef STK_MIXTURE_VERBOSE
166 stk_cout << _T("In SemiSEMPredict::run() iterations terminated.\n")
167 << _T("p_model_->lnLikelihood = ") << p_model_->lnLikelihood() << _T("\n");
168#endif
169 // set averaged parameters
171 p_model_->mapStep();
173#ifdef STK_MIXTURE_VERY_VERBOSE
174 stk_cout << _T("Terminating SemiSEMPredict::run()\n");
175 stk_cout << _T("---------------------------------\n");
176#endif
177 return true;
178}
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
bool predictBayesClassifier()
predict class labels when there is no missing values.
int nbIterLong_
maximal number of iterations of the algorithm
bool burnStep()
Perform burn step using SEM algorithm.
int nbIterBurn_
Number of burning iterations of the algorithm.
IMixtureComposer * p_model_
pointer on the mixture model
virtual void initializeStep()
Initialize the model before its first use.
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.
virtual void finalizeStep()
Finalize the estimation of the model.
int computeNbMissingValues() const
compute the missing values of the model.
virtual void setParametersStep()
Utility method allowing to signal to a mixture to set its parameters.
virtual void storeIntermediateResults(int iteration)
This step can be used to signal to the mixtures that they must store results.
virtual void samplingStep()
Simulation of all the latent variables and/or missing data excluding class labels.
String msg_error_
String with the last error message.
Definition STK_IRunner.h:96
String const & error() const
get the last error message.
Definition STK_IRunner.h:82
String exceptionToString(exceptions const &type)
convert a Clust::exceptions to a String.
exceptions
Specific exceptions allowing to handle the erroros that can occur in the estimation process.

References _T, STK::IMixtureAlgoPredict::burnStep(), STK::IMixtureStatModel::computeNbMissingValues(), STK::IRunnerBase::error(), STK::IMixtureComposer::eStep(), STK::Clust::exceptionToString(), STK::IMixtureComposer::finalizeStep(), STK::IMixtureComposer::initializeStep(), STK::IStatModelBase::lnLikelihood(), STK::IMixtureComposer::mapStep(), STK::IRunnerBase::msg_error_, STK::IMixtureAlgoPredict::nbIterBurn_, STK::IMixtureAlgoPredict::nbIterLong_, STK::IMixtureAlgoPredict::p_model_, STK::IMixtureAlgoPredict::predictBayesClassifier(), STK::IMixtureStatModel::samplingStep(), STK::IMixtureStatModel::setParametersStep(), stk_cout, and STK::IMixtureStatModel::storeIntermediateResults().


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