STK++ 0.9.13
STK_Clust_Util.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._DOT_I..._AT_stkpp.org (see copyright for ...)
23*/
24
25/*
26 * Project: stkpp::Clustering
27 * created on: 2 sept. 2013
28 * Author: iovleff, serge.iovleff@stkpp.org
29 * Originally created by Parmeet Bhatia <b..._DOT_p..._AT_gmail_Dot_com>
30 **/
31
38#ifndef STK_CLUST_UTIL_H
39#define STK_CLUST_UTIL_H
40
41#include <STKernel.h>
42
43namespace STK
44{
45
46// forward declaration
47class IMixtureAlgo;
48class IMixtureAlgoPredict;
49class IMixtureAlgoLearn;
50class IMixtureInit;
51class IMixtureStrategy;
52class IMixtureComposer;
53class IMixtureCriterion;
54
60template <int Id> struct ModelParameters;
61
67template <class Array_> struct HDMatrixModelParameters;
68
69namespace hidden
70{
76template<class Derived> struct MixtureBridgeTraits;
82template <class Mixture> struct MixtureTraits;
83
90template <class Manager> struct MixtureManagerTraits;
91
92} // namespace hidden
93
94
95namespace Clust
96{
97
115
133initType stringToInit( String const& type);
134
145
146
165algoType stringToAlgo( String const& type);
166
175
189
198
214
219{
221 XemStrategy_ = 1, // not implemented
223 FullStrategy_ = 3
225
230{
231 aic_ = 0,
232 bic_ = 1,
233 icl_ = 2,
234 ml_ = 3
236
252
271
278
291
350
351} // namespace Clust
352
353namespace hidden
354{
355template<int Id> struct HDCovarianceChooser;
356
357template<>
358struct HDCovarianceChooser<Clust::HDCovariance_AjkBkQkDk_>
359{
360 const bool isAj_ = true;
361 const bool isAk_ = true;
362 const bool isBk_ = true;
363 const bool isQk_ = true;
364 const bool isDk_ = true;
365};
366template<>
367struct HDCovarianceChooser<Clust::HDCovariance_AjkBkQkD_>
368{
369 const bool isAj_ = true;
370 const bool isAk_ = true;
371 const bool isBk_ = true;
372 const bool isQk_ = true;
373 const bool isDk_ = false;
374};
375template<>
376struct HDCovarianceChooser<Clust::HDCovariance_AjkBkQDk_>
377{
378 const bool isAj_ = true;
379 const bool isAk_ = true;
380 const bool isBk_ = true;
381 const bool isQk_ = false;
382 const bool isDk_ = true;
383};
384template<>
385struct HDCovarianceChooser<Clust::HDCovariance_AjkBkQD_>
386{
387 const bool isAj_ = true;
388 const bool isAk_ = true;
389 const bool isBk_ = true;
390 const bool isQk_ = false;
391 const bool isDk_ = false;
392};
393template<>
394struct HDCovarianceChooser<Clust::HDCovariance_AjkBQkDk_>
395{
396 const bool isAj_ = true;
397 const bool isAk_ = true;
398 const bool isBk_ = false;
399 const bool isQk_ = true;
400 const bool isDk_ = true;
401};
402template<>
403struct HDCovarianceChooser<Clust::HDCovariance_AjkBQkD_>
404{
405 const bool isAj_ = true;
406 const bool isAk_ = true;
407 const bool isBk_ = false;
408 const bool isQk_ = true;
409 const bool isDk_ = false;
410};
411template<>
412struct HDCovarianceChooser<Clust::HDCovariance_AjkBQDk_>
413{
414 const bool isAj_ = true;
415 const bool isAk_ = true;
416 const bool isBk_ = false;
417 const bool isQk_ = false;
418 const bool isDk_ = true;
419};
420template<>
421struct HDCovarianceChooser<Clust::HDCovariance_AjkBQD_>
422{
423 const bool isAj_ = true;
424 const bool isAk_ = true;
425 const bool isBk_ = false;
426 const bool isQk_ = false;
427 const bool isDk_ = false;
428};
429template<>
430struct HDCovarianceChooser<Clust::HDCovariance_AkBkQkDk_>
431{
432 const bool isAj_ = false;
433 const bool isAk_ = true;
434 const bool isBk_ = true;
435 const bool isQk_ = true;
436 const bool isDk_ = true;
437};
438template<>
439struct HDCovarianceChooser<Clust::HDCovariance_AkBkQkD_>
440{
441 const bool isAj_ = false;
442 const bool isAk_ = true;
443 const bool isBk_ = true;
444 const bool isQk_ = true;
445 const bool isDk_ = false;
446};
447template<>
448struct HDCovarianceChooser<Clust::HDCovariance_AkBkQDk_>
449{
450 const bool isAj_ = false;
451 const bool isAk_ = true;
452 const bool isBk_ = true;
453 const bool isQk_ = false;
454 const bool isDk_ = true;
455};
456template<>
457struct HDCovarianceChooser<Clust::HDCovariance_AkBkQD_>
458{
459 const bool isAj_ = false;
460 const bool isAk_ = true;
461 const bool isBk_ = true;
462 const bool isQk_ = false;
463 const bool isDk_ = false;
464};
465template<>
466struct HDCovarianceChooser<Clust::HDCovariance_AkBQkDk_>
467{
468 const bool isAj_ = false;
469 const bool isAk_ = true;
470 const bool isBk_ = false;
471 const bool isQk_ = true;
472 const bool isDk_ = true;
473};
474template<>
475struct HDCovarianceChooser<Clust::HDCovariance_AkBQkD_>
476{
477 const bool isAj_ = false;
478 const bool isAk_ = true;
479 const bool isBk_ = false;
480 const bool isQk_ = true;
481 const bool isDk_ = false;
482};
483template<>
484struct HDCovarianceChooser<Clust::HDCovariance_AkBQDk_>
485{
486 const bool isAj_ = false;
487 const bool isAk_ = true;
488 const bool isBk_ = false;
489 const bool isQk_ = false;
490 const bool isDk_ = true;
491};
492template<>
493struct HDCovarianceChooser<Clust::HDCovariance_AkBQD_>
494{
495 const bool isAj_ = false;
496 const bool isAk_ = true;
497 const bool isBk_ = false;
498 const bool isQk_ = false;
499 const bool isDk_ = false;
500};
501template<>
502struct HDCovarianceChooser<Clust::HDCovariance_AjBkQkDk_>
503{
504 const bool isAj_ = true;
505 const bool isAk_ = false;
506 const bool isBk_ = true;
507 const bool isQk_ = true;
508 const bool isDk_ = true;
509};
510template<>
511struct HDCovarianceChooser<Clust::HDCovariance_AjBkQkD_>
512{
513 const bool isAj_ = true;
514 const bool isAk_ = false;
515 const bool isBk_ = true;
516 const bool isQk_ = true;
517 const bool isDk_ = false;
518};
519template<>
520struct HDCovarianceChooser<Clust::HDCovariance_AjBkQDk_>
521{
522 const bool isAj_ = true;
523 const bool isAk_ = false;
524 const bool isBk_ = true;
525 const bool isQk_ = false;
526 const bool isDk_ = true;
527};
528template<>
529struct HDCovarianceChooser<Clust::HDCovariance_AjBkQD_>
530{
531 const bool isAj_ = true;
532 const bool isAk_ = false;
533 const bool isBk_ = true;
534 const bool isQk_ = false;
535 const bool isDk_ = false;
536};
537template<>
538struct HDCovarianceChooser<Clust::HDCovariance_AjBQkDk_>
539{
540 const bool isAj_ = true;
541 const bool isAk_ = false;
542 const bool isBk_ = false;
543 const bool isQk_ = true;
544 const bool isDk_ = true;
545};
546template<>
547struct HDCovarianceChooser<Clust::HDCovariance_AjBQkD_>
548{
549 const bool isAj_ = true;
550 const bool isAk_ = false;
551 const bool isBk_ = false;
552 const bool isQk_ = true;
553 const bool isDk_ = false;
554};
555template<>
556struct HDCovarianceChooser<Clust::HDCovariance_ABkQkDk_>
557{
558 const bool isAj_ = false;
559 const bool isAk_ = false;
560 const bool isBk_ = true;
561 const bool isQk_ = true;
562 const bool isDk_ = true;
563};
564template<>
565struct HDCovarianceChooser<Clust::HDCovariance_ABkQkD_>
566{
567 const bool isAj_ = false;
568 const bool isAk_ = false;
569 const bool isBk_ = true;
570 const bool isQk_ = true;
571 const bool isDk_ = false;
572};
573template<>
574struct HDCovarianceChooser<Clust::HDCovariance_ABkQDk_>
575{
576 const bool isAj_ = false;
577 const bool isAk_ = false;
578 const bool isBk_ = true;
579 const bool isQk_ = false;
580 const bool isDk_ = true;
581};
582template<>
583struct HDCovarianceChooser<Clust::HDCovariance_ABkQD_>
584{
585 const bool isAj_ = false;
586 const bool isAk_ = false;
587 const bool isBk_ = true;
588 const bool isQk_ = false;
589 const bool isDk_ = false;
590};
591template<>
592struct HDCovarianceChooser<Clust::HDCovariance_ABQkDk_>
593{
594 const bool isAj_ = false;
595 const bool isAk_ = false;
596 const bool isBk_ = false;
597 const bool isQk_ = true;
598 const bool isDk_ = true;
599};
600template<>
601struct HDCovarianceChooser<Clust::HDCovariance_ABQkD_>
602{
603 const bool isAj_ = false;
604 const bool isAk_ = false;
605 const bool isBk_ = false;
606 const bool isQk_ = true;
607 const bool isDk_ = false;
608};
609
610} // namespace hidden
611
612namespace Clust
613{
674
690
753Mixture stringToMixture( String const& type);
754
819Mixture stringToMixture( String const& type, bool& freeProp);
820
826String mixtureToString( Mixture const& type);
827
837
844
847const int defaultNbTry = 5;
848
854const int defaultNbInit = 5;
864
874
880const int defaultMaxIterLongRun = 1000;
884
890
895
901IMixtureAlgo* createAlgo( Clust::algoType algo, int nbIterMax, Real epsilon);
902
909
917
926 , int nbInits = defaultNbInit
928 , int nbIterMax = defaultNbIterMaxInInit
929 , Real epsilon = defaultEpsilonInInit);
937 , int nbIterMax = defaultMaxIterShortRun
938 , Real epsilon = defaultEpsilonShortRun)
939{ return createAlgo(algo, nbIterMax, epsilon);}
947 , int nbIterMax = defaultMaxIterLongRun
948 , Real epsilon = defaultEpsilonLongRun)
949{ return createAlgo(algo, nbIterMax, epsilon);}
950
960 , int nbTry
961 , IMixtureInit* const& p_init
962 , IMixtureAlgo* const& algo);
963
976 , int nbTry, int nbInitRun
977 , IMixtureInit* const& p_init
979 , IMixtureAlgo* const& longRunAlgo);
980} // namespace Clust
981
982} // namespace STK
983
984#endif /* STK_CLUST_UTIL_H */
This file include all the header files of the project STKernel.
Interface base class for the learning algorithms.
Interface base class for predicting algorithms.
Interface base class for the algorithms.
Base class for Mixture (composed) model.
Interface base class for the selection model criterion.
Interface base class for the initializations.
Interface base class for all the strategies.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
algoPredictType
Learning estimation algorithms.
const Clust::initType defaultInitType
Default algorithm type in short run.
IMixtureAlgo * createLongRunAlgo(Clust::algoType algo=defaultAlgoLongRun, int nbIterMax=defaultMaxIterLongRun, Real epsilon=defaultEpsilonLongRun)
utility function for creating a long Run algorithm.
const int defaultMaxIterShortRun
Default number of iterations in the short runs (used in FullStrategy)
const int defaultNbInit
Default number of initializations to perform.
const Clust::algoType defaultAlgoShortRun
Default algorithm type in short run.
initType
initialization type.
const Clust::algoType defaultAlgoInInit
Default algorithm type in initialization.
algoType
Estimation algorithms.
const Clust::algoType defaultAlgoLongRun
Default algorithm type in long run.
MixtureClass
list of the class of mixture implemented in stkpp
algoType stringToAlgo(String const &type)
Convert a String to an algoType.
initType stringToInit(String const &type)
Convert a String to a initType.
const int defaultMaxIterLongRun
Default number of iterations in the long run (used in FullStrategy)
MixtureClass mixtureToMixtureClass(Mixture const &type)
convert a Mixture to a MixtureClass.
algoLearnType
Learning estimation algorithms.
const Real defaultEpsilonInInit
Default epsilon in the short runs (used in strategy)
ParsimoniousCovarianceModel
list of the parsimonious covariance models that can be used
IMixtureAlgo * createShortRunAlgo(Clust::algoType algo=defaultAlgoShortRun, int nbIterMax=defaultMaxIterShortRun, Real epsilon=defaultEpsilonShortRun)
utility function for creating a a short Run algorithm.
const Real defaultEpsilonLongRun
Default epsilon in the long run (used in strategy)
IMixtureInit * createInit(Clust::initType init=defaultInitType, int nbInits=defaultNbInit, Clust::algoType algo=defaultAlgoInInit, int nbIterMax=defaultNbIterMaxInInit, Real epsilon=defaultEpsilonInInit)
Utility function for creating a model initializer.
IMixtureAlgo * createAlgo(Clust::algoType algo, int nbIterMax, Real epsilon)
utility function for creating an estimation algorithm.
algoPredictType stringToPredictAlgo(String const &type)
Convert a String to an algoPredictType.
IMixtureStrategy * createSimpleStrategy(IMixtureComposer *&p_composer, int nbTry, IMixtureInit *const &p_init, IMixtureAlgo *const &algo)
Utility function for creating a SimpleStrategy.
IMixtureCriterion * createCriterion(Clust::criterionType criterion)
criterionType stringToCriterion(String const &type)
Convert a String to an criterionType.
Mixture stringToMixture(String const &type)
Convert a String to a Mixture.
strategyType
strategy of estimation
String mixtureToString(Mixture const &type)
convert a Mixture to a String.
String exceptionToString(exceptions const &type)
convert a Clust::exceptions to a String.
const Real defaultEpsilonShortRun
Default epsilon in the short runs (used in strategy)
const int defaultNbTry
Default number of try in an estimation strategy.
IMixtureAlgoLearn * createLearnAlgo(Clust::algoLearnType algo, int nbIterMax, Real epsilon)
utility function for creating a learning algorithm.
algoLearnType stringToLearnAlgo(String const &type)
Convert a String to an algoLearnType.
exceptions
Specific exceptions allowing to handle the erroros that can occur in the estimation process.
Mixture
list of the mixtures that can be used by the composer
IMixtureStrategy * createFullStrategy(IMixtureComposer *&p_composer, int nbTry, int nbInitRun, IMixtureInit *const &p_init, int nbShortRun, IMixtureAlgo *const &shortRunAlgo, IMixtureAlgo *const &longRunAlgo)
Utility function for creating a FullStrategy.
IMixtureAlgoPredict * createPredictAlgo(Clust::algoPredictType algo, int nbIterBurn, int nbIterLong, Real epsilon)
utility function for creating a predicting algorithm.
criterionType
type of criterion to use in order to select the mixture model
HDCovarianceModel
list of the HD covariance models that can be used
const int defaultNbIterMaxInInit
Default number of iteration in an initialization algorithm.
modelState
Give the state of the model.
@ randomParamInit_
initialize randomly the parameters
@ valueParamInit_
initialize parameters using given values
@ randomFuzzyInit_
initialize randomly the partnership class probabilities
@ randomClassInit_
initialize randomly the class labels
@ randomInit_
DEPRECATED.
@ noInit_
no initialization
@ modelCreated_
the model has been created but is not initialized
@ longRun_
A long run has been done.
@ modelInitialized_
the model is initialized and its parameters are initialized to default values
@ modelFinalized_
the model is finalized
@ modelParamInitialized_
The parameters of the model have been initialized.
@ shortRun_
A short run has been done.
std::basic_string< Char > String
STK fundamental type of a String.
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.
structure storing the parameters of the HD matrix valued mixture
struct storing the parameters of the mixture.
MixtureBridgeTraits struct for bridged mixtures The traits struct MixtureBridgeTraits must be special...
Main class for the mixture managers traits policy.
Main class for the mixtures traits policy.