27 #ifndef GRT_GESTURE_RECOGNITION_PIPELINE_HEADER 28 #define GRT_GESTURE_RECOGNITION_PIPELINE_HEADER 30 #include "../Util/GRTCommon.h" 38 #include "../DataStructures/ClassificationDataStream.h" 39 #include "../Util/ClassificationResult.h" 40 #include "../Util/TestResult.h" 44 #define INSERT_AT_END_INDEX 99999 56 enum ContextLevels{START_OF_PIPELINE=0,AFTER_PREPROCESSING,AFTER_FEATURE_EXTRACTION,AFTER_CLASSIFIER,END_OF_PIPELINE,NUM_CONTEXT_LEVELS};
146 virtual bool train(
const ClassificationData &trainingData,
const UINT kFoldValue,
const bool useStratifiedSampling =
false );
159 virtual bool train_(
ClassificationData &trainingData,
const UINT kFoldValue,
const bool useStratifiedSampling =
false);
334 GRT_DEPRECATED_MSG(
"map_(VectorFloat &inputVector) is deprecated, use predict_(VectorFloat &inputVector) instead",
virtual bool map_(
VectorFloat &inputVector)
override );
342 virtual bool reset()
override;
350 virtual bool clear()
override;
358 virtual bool clearModel();
366 virtual bool save(
const std::string &filename)
const override;
373 GRT_DEPRECATED_MSG(
"savePipelineToFile(std::string filename) is deprecated, use save(std::string &filename) instead",
bool savePipelineToFile(
const std::string &filename)
const );
382 virtual bool load(
const std::string &filename)
override;
389 GRT_DEPRECATED_MSG(
"loadPipelineFromFile(std::string filename) is deprecated, use load(std::string &filename) instead",
bool loadPipelineFromFile(
const std::string &filename) );
405 bool preProcessData(
VectorFloat inputVector,
bool computeFeatures =
true);
412 virtual bool getIsInitialized()
const;
419 bool getIsPreProcessingSet()
const;
426 bool getIsFeatureExtractionSet()
const;
433 bool getIsClassifierSet()
const;
440 bool getIsRegressifierSet()
const;
447 bool getIsClustererSet()
const;
454 bool getIsPostProcessingSet()
const;
461 bool getIsContextSet()
const;
468 bool getIsPipelineModeSet()
const;
475 bool getIsPipelineInClassificationMode()
const;
482 bool getIsPipelineInRegressionMode()
const;
489 UINT getInputVectorDimensionsSize()
const;
497 UINT getOutputVectorDimensionsSize()
const;
504 UINT getNumClassesInModel()
const;
512 UINT getNumClasses()
const;
519 UINT getNumPreProcessingModules()
const;
526 UINT getNumFeatureExtractionModules()
const;
533 UINT getNumPostProcessingModules()
const;
543 UINT getPredictionModuleIndexPosition()
const;
550 UINT getPredictedClassLabel()
const;
558 UINT getUnProcessedPredictedClassLabel()
const;
565 UINT getNumTrainingSamples()
const;
572 UINT getNumTestSamples()
const;
579 Float getMaximumLikelihood()
const;
586 Float getPhase()
const;
593 Float getTrainingSetAccuracy()
const;
602 Float getCrossValidationAccuracy()
const;
609 Float getTestAccuracy()
const;
616 Float getTestRMSError()
const;
623 Float getTestSSError()
const;
632 Float getTestFMeasure(
const UINT classLabel)
const;
641 Float getTestPrecision(
const UINT classLabel)
const;
650 Float getTestRecall(
const UINT classLabel)
const;
658 Float getTestRejectionPrecision()
const;
666 Float getTestRejectionRecall()
const;
673 Float getTestTime()
const;
680 Float getTrainingTime()
const;
687 Float getTrainingRMSError()
const;
694 Float getTrainingSSError()
const;
796 VectorFloat getPreProcessedData(UINT moduleIndex)
const;
811 VectorFloat getFeatureExtractionData(
const UINT moduleIndex)
const;
841 PreProcessing* getPreProcessingModule(
const UINT moduleIndex)
const;
887 Context* getContextModule(
const UINT contextLevel,
const UINT moduleIndex)
const;
896 if( moduleIndex < preProcessingModules.getSize() ){
898 if( preProcessingModules[ moduleIndex ] == NULL )
return NULL;
900 if( T::getId() == preProcessingModules[ moduleIndex ]->getId() ){
901 return dynamic_cast<const T*
>( preProcessingModules[ moduleIndex ] );
915 if( moduleIndex < preProcessingModules.getSize() ){
917 if( preProcessingModules[ moduleIndex ] == NULL )
return NULL;
919 if( T::getId() == preProcessingModules[ moduleIndex ]->getId() ){
920 return dynamic_cast<T*
>( preProcessingModules[ moduleIndex ] );
934 if( moduleIndex < featureExtractionModules.getSize() ){
936 if( featureExtractionModules[ moduleIndex ] == NULL )
return NULL;
938 if( T::getId() == featureExtractionModules[ moduleIndex ]->getId() ){
939 return dynamic_cast<const T*
>( featureExtractionModules[ moduleIndex ] );
953 if( moduleIndex < featureExtractionModules.getSize() ){
955 if( featureExtractionModules[ moduleIndex ] == NULL )
return NULL;
957 if( T::getId() == featureExtractionModules[ moduleIndex ]->getId() ){
958 return dynamic_cast<T*
>( featureExtractionModules[ moduleIndex ] );
973 if( classifier == NULL )
return NULL;
975 if( T::getId() == classifier->getId() ){
976 return dynamic_cast<const T*
>( classifier );
990 if( classifier == NULL )
return NULL;
992 if( T::getId() == classifier->getId() ){
993 return dynamic_cast<T*
>( classifier );
1007 if( regressifier == NULL )
return NULL;
1009 if( T::getId() == regressifier->getId() ){
1010 return dynamic_cast<const T*
>( regressifier );
1024 if( regressifier == NULL )
return NULL;
1026 if( T::getId() == regressifier->getId() ){
1027 return dynamic_cast<T*
>( regressifier );
1041 if( clusterer == NULL )
return NULL;
1043 if( T::getId() == clusterer->getId() ){
1044 return dynamic_cast<const T*
>( clusterer );
1058 if( clusterer == NULL )
return NULL;
1060 if( T::getId() == clusterer->getId() ){
1061 return dynamic_cast<T*
>( clusterer );
1074 if( moduleIndex < postProcessingModules.getSize() ){
1075 if( postProcessingModules[ moduleIndex ] == NULL )
return NULL;
1077 if( T::getId() == postProcessingModules[ moduleIndex ]->getId() ){
1078 return dynamic_cast<const T*
>( postProcessingModules[ moduleIndex ] );
1091 if( moduleIndex < postProcessingModules.getSize() ){
1092 if( postProcessingModules[ moduleIndex ] == NULL )
return NULL;
1094 if( T::getId() == postProcessingModules[ moduleIndex ]->getId() ){
1095 return dynamic_cast<T*
>( postProcessingModules[ moduleIndex ] );
1108 template <
class T> T*
const getContextModule(
const UINT contextLevel,
const UINT moduleIndex)
const{
1109 if( contextLevel < contextModules.getSize() ){
1110 if( moduleIndex >= contextModules[ contextLevel ].getSize() ){
1114 if( contextModules[ contextLevel ][ moduleIndex ] == NULL )
return NULL;
1116 if( T::getId() == contextModules[ contextLevel ][ moduleIndex ]->getId() ){
1117 return dynamic_cast<const T*
>(contextModules[ contextLevel ][ moduleIndex ]);
1131 if( contextLevel < contextModules.getSize() ){
1132 if( moduleIndex >= contextModules[ contextLevel ].getSize() ){
1136 if( contextModules[ contextLevel ][ moduleIndex ] == NULL )
return NULL;
1138 if( T::getId() == contextModules[ contextLevel ][ moduleIndex ]->getId() ){
1139 return dynamic_cast<T*
>(contextModules[ contextLevel ][ moduleIndex ]);
1157 std::string getPipelineModeAsString()
const;
1164 std::string getInfo()
const;
1172 UINT getPipelineModeFromString(std::string pipelineMode)
const;
1190 bool setPreProcessingModule(
const PreProcessing &preProcessingModule);
1208 bool setFeatureExtractionModule(
const FeatureExtraction &featureExtractionModule);
1216 bool setClassifier(
const Classifier &classifier);
1224 bool setRegressifier(
const Regressifier ®ressifier);
1232 bool setClusterer(
const Clusterer &clusterer);
1250 bool setPostProcessingModule(
const PostProcessing &postProcessingModule);
1272 bool updateContextModule(
bool value,UINT contextLevel = 0,UINT moduleIndex = 0);
1279 bool removeAllPreProcessingModules();
1287 bool removePreProcessingModule(UINT moduleIndex);
1294 bool removeAllFeatureExtractionModules();
1302 bool removeFeatureExtractionModule(UINT moduleIndex);
1330 bool removeAllPostProcessingModules();
1338 bool removePostProcessingModule(
const UINT moduleIndex);
1345 bool removeAllContextModules();
1354 bool removeContextModule(
const UINT contextLevel,
const UINT moduleIndex);
1369 bool clearTestResults();
1375 bool setInfo(
const std::string &info);
1383 bool predict_classifier(
const VectorFloat &inputVector);
1384 bool predict_timeseries(
const MatrixFloat &input );
1386 bool predict_regressifier(
const VectorFloat &inputVector);
1387 bool predict_clusterer(
const VectorFloat &inputVector);
1388 void deleteAllPreProcessingModules();
1389 void deleteAllFeatureExtractionModules();
1390 void deleteClassifier();
1391 void deleteRegressifier();
1392 void deleteClusterer();
1393 void deleteAllPostProcessingModules();
1394 void deleteAllContextModules();
1395 bool updateTestMetrics(
const UINT classLabel,
const UINT predictedClassLabel,
VectorFloat &precisionCounter,
VectorFloat &recallCounter,Float &rejectionPrecisionCounter,Float &rejectionRecallCounter,
VectorFloat &confusionMatrixCounter);
1396 bool computeTestMetrics(
VectorFloat &precisionCounter,
VectorFloat &recallCounter,Float &rejectionPrecisionCounter,Float &rejectionRecallCounter,
VectorFloat &confusionMatrixCounter,
const UINT numTestSamples);
1400 UINT inputVectorDimensions;
1401 UINT outputVectorDimensions;
1402 UINT predictedClassLabel;
1403 UINT predictedClusterLabel;
1405 UINT predictionModuleIndex;
1406 UINT numTrainingSamples;
1407 UINT numTestSamples;
1410 Float testSquaredError;
1417 Float testRejectionPrecision;
1418 Float testRejectionRecall;
1431 enum PipelineModes{PIPELINE_MODE_NOT_SET=0,CLASSIFICATION_MODE,REGRESSION_MODE,CLUSTER_MODE};
1436 #endif //GRT_GESTURE_RECOGNITION_PIPELINE_HEADER
const T * getRegressifier() const
virtual bool predict(VectorFloat inputVector)
This is the main base class that all GRT Clustering algorithms should inherit from.
virtual bool predict_(VectorFloat &inputVector)
virtual bool train(ClassificationData trainingData)
virtual bool save(const std::string &filename) const
T * getPostProcessingModule(const UINT moduleIndex)
T * getContextModule(const UINT contextLevel, const UINT moduleIndex)
This is the main base class that all GRT PostProcessing algorithms should inherit from...
T * getPreProcessingModule(const UINT moduleIndex)
virtual std::string getModelAsString() const
T * getFeatureExtractionModule(const UINT moduleIndex)
const T * getPreProcessingModule(const UINT moduleIndex) const
virtual bool train_(ClassificationData &trainingData)
GRT_DEPRECATED_MSG("saveModelToFile(std::string filename) is deprecated, use save(const std::string &filename) instead", virtual bool saveModelToFile(const std::string &filename) const )
T *const getContextModule(const UINT contextLevel, const UINT moduleIndex) const
#define INSERT_AT_END_INDEX
This is the main base class that all GRT PreProcessing algorithms should inherit from.
const T * getClassifier() const
virtual bool map_(VectorFloat &inputVector)
bool removeRegressifier()
const T * getCluster() const
virtual bool load(const std::string &filename)
Vector< TrainingResult > getTrainingResults() const
const T * getFeatureExtractionModule(const UINT moduleIndex) const
const T * getPostProcessingModule(const UINT moduleIndex) const
This is the main base class that all GRT machine learning algorithms should inherit from...
This is the main base class that all GRT Classification algorithms should inherit from...
This is the main base class that all GRT Feature Extraction algorithms should inherit from...
This is the main base class that all GRT Regression algorithms should inherit from.