STK++ 0.9.13
STK::ClassInit Class Reference

Initialization by simulating a realization of the class labels zi accordingly to the initial proportions. More...

#include <STK_MixtureInit.h>

Inheritance diagram for STK::ClassInit:
Inheritance graph

Public Member Functions

 ClassInit ()
 default constructor
 
 ClassInit (ClassInit const &init)
 copy constructor
 
virtual ~ClassInit ()
 destructor
 
virtual ClassInitclone () const
 clone pattern
 
virtual bool run ()
 run the initialization by calling the randomClassInit method of the model.
 
- 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 a realization of the class labels zi accordingly to the initial proportions.

Definition at line 69 of file STK_MixtureInit.h.

Constructor & Destructor Documentation

◆ ClassInit() [1/2]

STK::ClassInit::ClassInit ( )
inline

default constructor

Definition at line 73 of file STK_MixtureInit.h.

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

Referenced by clone().

◆ ClassInit() [2/2]

STK::ClassInit::ClassInit ( ClassInit const init)
inline

copy constructor

Parameters
initthe initialization to copy

Definition at line 77 of file STK_MixtureInit.h.

77: IMixtureInit(init) {}

◆ ~ClassInit()

virtual STK::ClassInit::~ClassInit ( )
inlinevirtual

destructor

Definition at line 79 of file STK_MixtureInit.h.

79{}

Member Function Documentation

◆ clone()

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

clone pattern

Implements STK::IMixtureInit.

Definition at line 81 of file STK_MixtureInit.h.

81{ return new ClassInit(*this);}
ClassInit()
default constructor

References ClassInit().

◆ run()

bool STK::ClassInit::run ( )
virtual

run the initialization by calling the randomClassInit method of the model.

Returns
true if no error occur, false otherwise

Implements STK::IRunnerBase.

Definition at line 116 of file STK_MixtureInit.cpp.

117{
118#ifdef STK_MIXTURE_VERY_VERBOSE
119 stk_cout << _T("-------------------------\n")
120 << _T("Entering ClassInit::run()\n")
121 << _T("nbTry = ") << nbTry_ << _T("\n");
122#endif
123 bool result = false;
124 int iTry;
125 for (iTry= 0; iTry < nbTry_; ++iTry)
126 {
127 try
128 {
131 if (runInitAlgo()) { result = true; break;}
132#ifdef STK_MIXTURE_VERBOSE
133 stk_cout << _T("In ClassInit::run(), try number: ") << iTry << _T(" runInitAlgo() failed.\n");
134 stk_cout << _T("What: ") << p_initAlgo_->error() << _T("\n");
135#endif
136 msg_error_ = STKERROR_NO_ARG(ClassInit::run,Init algo failed\n);
138 }
139 catch (Clust::exceptions const& error)
140 {
143#ifdef STK_MIXTURE_VERBOSE
144 stk_cout << _T("In ClassInit::run(), try number") << iTry << " generate an exception.\n";
145 stk_cout << _T("In ClassInit::run(), error") << msg_error_ << _T("\n");
146#endif
147 }
148 catch (Exception const& error)
149 {
150 String msg = error.error();
152#ifdef STK_MIXTURE_VERBOSE
153 stk_cout << _T("In ClassInit::run(), try number") << iTry << " generate an exception.\n";
154 stk_cout << _T("In ClassInit::run(), error") << msg_error_ << _T("\n");
155#endif
156 }
157 }
158#ifdef STK_MIXTURE_VERY_VERBOSE
159 stk_cout << _T("Exiting ClassInit::run()\n")
160 << _T("------------------------\n");
161#endif
162 return result;
163}
#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 void initializeStep()
Initialize the model before its first use.
void randomClassInit()
Initialize randomly the labels zi of the model.
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::randomClassInit(), run(), STK::IMixtureInit::runInitAlgo(), stk_cout, and STKERROR_NO_ARG.

Referenced by STK::RandomInit::run(), run(), STK::FuzzyInit::run(), and STK::IMixtureInit::runInitAlgo().


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