STK++ 0.9.13
STK::FuzzyInit Class Reference

Initialization by simulating the tik accordingly to the initial proportions. More...

#include <STK_MixtureInit.h>

Inheritance diagram for STK::FuzzyInit:
Inheritance graph

Public Member Functions

 FuzzyInit ()
 default constructor
 
 FuzzyInit (FuzzyInit const &init)
 copy constructor
 
virtual ~FuzzyInit ()
 destructor
 
virtual FuzzyInitclone () const
 clone pattern
 
virtual bool run ()
 run the algorithm on the model calling E step and M step.
 
- Public Member Functions inherited from STK::IMixtureInit
virtual ~IMixtureInit ()
 destructor
 
IMixtureAlgo const *const p_initAlgo () const
 set a the number of try
 
int nbTry () const
 
void setNbTry (int nbTry)
 set a the number of try
 
void setModel (IMixtureComposer *p_model)
 set a new model
 
void setInitAlgo (IMixtureAlgo *p_initAlgo)
 set the initial algorithm

 
- Public Member Functions inherited from STK::IRunnerBase
String consterror () const
 get the last error message.
 

Additional Inherited Members

- Protected Member Functions inherited from STK::IMixtureInit
 IMixtureInit ()
 default constructor
 
 IMixtureInit (IMixtureInit const &init)
 copy constructor.
 
bool runInitAlgo ()
 launch the initialization 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::IMixtureInit
int nbTry_
 number of retry in initialization
 
IMixtureComposerp_model_
 pointer on the mixture model
 
IMixtureAlgop_initAlgo_
 algorithm to use in the initialization
 
- 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

Initialization by simulating the tik accordingly to the initial proportions.

Definition at line 90 of file STK_MixtureInit.h.

Constructor & Destructor Documentation

◆ FuzzyInit() [1/2]

STK::FuzzyInit::FuzzyInit ( )
inline

default constructor

Definition at line 94 of file STK_MixtureInit.h.

94: IMixtureInit() {}
IMixtureInit()
default constructor

Referenced by clone().

◆ FuzzyInit() [2/2]

STK::FuzzyInit::FuzzyInit ( FuzzyInit const init)
inline

copy constructor

Parameters
initthe initialization to copy

Definition at line 98 of file STK_MixtureInit.h.

98: IMixtureInit(init) {}

◆ ~FuzzyInit()

virtual STK::FuzzyInit::~FuzzyInit ( )
inlinevirtual

destructor

Definition at line 100 of file STK_MixtureInit.h.

100{}

Member Function Documentation

◆ clone()

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

clone pattern

Implements STK::IMixtureInit.

Definition at line 102 of file STK_MixtureInit.h.

102{ return new FuzzyInit(*this);}
FuzzyInit()
default constructor

References FuzzyInit().

◆ run()

bool STK::FuzzyInit::run ( )
virtual

run the algorithm on the model calling E step and M step.

Returns
true if no error occur, false otherwise

Implements STK::IRunnerBase.

Definition at line 167 of file STK_MixtureInit.cpp.

168{
169#ifdef STK_MIXTURE_VERY_VERBOSE
170 stk_cout << _T("-------------------------\n")
171 << _T("Entering FuzzyInit::run()\n")
172 << _T("nbTry = ") << nbTry_ << _T("\n");
173#endif
174 bool result = false;
175 int iTry;
176 for (iTry= 0; iTry < nbTry_; ++iTry)
177 {
178 try
179 {
182 if (runInitAlgo()) { result = true; break;}
183#ifdef STK_MIXTURE_VERBOSE
184 stk_cout << _T("In FuzzyInit::run(), try number") << iTry << " runInitAlgo() failed.\n";
185#endif
186 msg_error_ = STKERROR_NO_ARG(FuzzyInit::run,Init algo failed\n);
188 }
189 catch (Clust::exceptions const& error)
190 {
193#ifdef STK_MIXTURE_VERBOSE
194 stk_cout << _T("In FuzzyInit::run(), try number") << iTry << _T(" generate an exception.\n");
195 stk_cout << _T("In FuzzyInit::run(), error") << msg_error_ << _T("\n");
196#endif
197 }
198 catch (Exception const& error)
199 {
200 String msg = error.error();
202#ifdef STK_MIXTURE_VERBOSE
203 stk_cout << _T("In FuzzyInit::run(), try number") << iTry << " generate an exception.\n";
204 stk_cout << _T("In FuzzyInit::run(), error") << msg_error_ << _T("\n");
205#endif
206 }
207 } // iTry
208#ifdef STK_MIXTURE_VERBOSE
209 stk_cout << _T("Exiting FuzzyInit::run()\n")
210 << _T("------------------------\n");
211#endif
212 return result;
213}
#define STKERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:49
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
virtual bool run()
run the initialization by calling the randomClassInit method of the model.
virtual bool run()
run the algorithm on the model calling E step and M step.
virtual void initializeStep()
Initialize the model before its first use.
void randomFuzzyInit()
Initialize randomly the posterior probabilities tik of the model, then compute the zi values with map...
IMixtureComposer * p_model_
pointer on the mixture model
IMixtureAlgo * p_initAlgo_
algorithm to use in the initialization
bool runInitAlgo()
launch the initialization algorithm.
int nbTry_
number of retry in initialization
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.
std::basic_string< Char > String
STK fundamental type of a String.

References _T, STK::IRunnerBase::error(), STK::Clust::exceptionToString(), STK::IMixtureComposer::initializeStep(), STK::IRunnerBase::msg_error_, STK::IMixtureInit::nbTry_, STK::IMixtureInit::p_initAlgo_, STK::IMixtureInit::p_model_, STK::IMixtureComposer::randomFuzzyInit(), STK::ClassInit::run(), run(), STK::IMixtureInit::runInitAlgo(), stk_cout, and STKERROR_NO_ARG.

Referenced by run().


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