35 #ifndef GRT_GESTURE_RECOGNITION_PIPELINE_HEADER
36 #define GRT_GESTURE_RECOGNITION_PIPELINE_HEADER
38 #include "../Util/GRTCommon.h"
46 #include "../DataStructures/ClassificationDataStream.h"
47 #include "../Util/ClassificationResult.h"
48 #include "../Util/TestResult.h"
52 #define INSERT_AT_END_INDEX 99999
57 enum ContextLevels{START_OF_PIPELINE=0,AFTER_PREPROCESSING,AFTER_FEATURE_EXTRACTION,AFTER_CLASSIFIER,END_OF_PIPELINE,NUM_CONTEXT_LEVELS};
149 bool train(
const ClassificationData &trainingData,
const UINT kFoldValue,
const bool useStratifiedSampling =
false );
206 bool train(
const RegressionData &trainingData,
const UINT kFoldValue);
323 bool save(
const std::string &filename)
const;
331 bool savePipelineToFile(
const std::string &filename)
const;
340 bool load(
const std::string &filename);
348 bool loadPipelineFromFile(
const std::string &filename);
364 bool preProcessData(
VectorFloat inputVector,
bool computeFeatures =
true);
371 bool getIsInitialized()
const;
378 bool getTrained()
const;
385 bool getIsPreProcessingSet()
const;
392 bool getIsFeatureExtractionSet()
const;
399 bool getIsClassifierSet()
const;
406 bool getIsRegressifierSet()
const;
413 bool getIsClustererSet()
const;
420 bool getIsPostProcessingSet()
const;
427 bool getIsContextSet()
const;
434 bool getIsPipelineModeSet()
const;
441 bool getIsPipelineInClassificationMode()
const;
448 bool getIsPipelineInRegressionMode()
const;
455 UINT getInputVectorDimensionsSize()
const;
463 UINT getOutputVectorDimensionsSize()
const;
470 UINT getNumClassesInModel()
const;
478 UINT getNumClasses()
const;
485 UINT getNumPreProcessingModules()
const;
492 UINT getNumFeatureExtractionModules()
const;
499 UINT getNumPostProcessingModules()
const;
509 UINT getPredictionModuleIndexPosition()
const;
516 UINT getPredictedClassLabel()
const;
524 UINT getUnProcessedPredictedClassLabel()
const;
531 UINT getNumTrainingSamples()
const;
538 UINT getNumTestSamples()
const;
545 Float getMaximumLikelihood()
const;
552 Float getPhase()
const;
561 Float getCrossValidationAccuracy()
const;
568 Float getTestAccuracy()
const;
575 Float getTestRMSError()
const;
582 Float getTestSSError()
const;
591 Float getTestFMeasure(
const UINT classLabel)
const;
600 Float getTestPrecision(
const UINT classLabel)
const;
609 Float getTestRecall(
const UINT classLabel)
const;
617 Float getTestRejectionPrecision()
const;
625 Float getTestRejectionRecall()
const;
632 Float getTestTime()
const;
639 Float getTrainingTime()
const;
646 Float getTrainingRMSError()
const;
653 Float getTrainingSSError()
const;
670 TestResult getTestResults()
const;
746 VectorFloat getPreProcessedData(UINT moduleIndex)
const;
761 VectorFloat getFeatureExtractionData(
const UINT moduleIndex)
const;
791 PreProcessing* getPreProcessingModule(
const UINT moduleIndex)
const;
837 Context* getContextModule(
const UINT contextLevel,
const UINT moduleIndex)
const;
846 if( moduleIndex < preProcessingModules.size() ){
847 return (T*)preProcessingModules[ moduleIndex ];
859 if( moduleIndex < featureExtractionModules.size() ){
860 return (T*)featureExtractionModules[ moduleIndex ];
873 if( classifier == NULL )
return NULL;
877 if( temp.getClassifierType() == classifier->getClassifierType() ){
878 return dynamic_cast<T*
>(classifier);
892 if( regressifier == NULL )
return NULL;
896 if( temp.getRegressifierType() == regressifier->getRegressifierType() ){
897 return (T*)regressifier;
911 if( clusterer == NULL )
return NULL;
915 if( temp.getClassifierType() == clusterer->getClustererType() ){
916 return (T*)clusterer;
929 if( moduleIndex < postProcessingModules.getSize() ){
930 return (T*)postProcessingModules[ moduleIndex ];
942 template <
class T> T*
getContextModule(
const UINT contextLevel,
const UINT moduleIndex)
const{
943 if( contextLevel < contextModules.getSize() ){
944 if( moduleIndex < contextModules[ contextLevel ].getSize() ){
945 return (T*)contextModules[ contextLevel ][ moduleIndex ];
956 std::string getModelAsString()
const;
963 std::string getPipelineModeAsString()
const;
970 std::string getInfo()
const;
978 UINT getPipelineModeFromString(std::string pipelineMode)
const;
996 bool setPreProcessingModule(
const PreProcessing &preProcessingModule);
1014 bool setFeatureExtractionModule(
const FeatureExtraction &featureExtractionModule);
1022 bool setClassifier(
const Classifier &classifier);
1030 bool setRegressifier(
const Regressifier ®ressifier);
1038 bool setClusterer(
const Clusterer &clusterer);
1056 bool setPostProcessingModule(
const PostProcessing &postProcessingModule);
1078 bool updateContextModule(
bool value,UINT contextLevel = 0,UINT moduleIndex = 0);
1085 bool removeAllPreProcessingModules();
1093 bool removePreProcessingModule(UINT moduleIndex);
1100 bool removeAllFeatureExtractionModules();
1108 bool removeFeatureExtractionModule(UINT moduleIndex);
1136 bool removeAllPostProcessingModules();
1144 bool removePostProcessingModule(
const UINT moduleIndex);
1151 bool removeAllContextModules();
1160 bool removeContextModule(
const UINT contextLevel,
const UINT moduleIndex);
1168 GRT_DEPRECATED_MSG(
"use clear() instead.",
bool clearAll() );
1175 bool clearTestResults();
1181 bool setInfo(
const std::string &info);
1184 bool predict_classifier(
const VectorFloat &inputVector);
1185 bool predict_timeseries(
const MatrixFloat &input );
1187 bool predict_regressifier(
const VectorFloat &inputVector);
1188 bool predict_clusterer(
const VectorFloat &inputVector);
1190 void deleteAllPreProcessingModules();
1191 void deleteAllFeatureExtractionModules();
1192 void deleteClassifier();
1193 void deleteRegressifier();
1194 void deleteClusterer();
1195 void deleteAllPostProcessingModules();
1196 void deleteAllContextModules();
1197 bool updateTestMetrics(
const UINT classLabel,
const UINT predictedClassLabel,
VectorFloat &precisionCounter,
VectorFloat &recallCounter,Float &rejectionPrecisionCounter,Float &rejectionRecallCounter,
VectorFloat &confusionMatrixCounter);
1198 bool computeTestMetrics(
VectorFloat &precisionCounter,
VectorFloat &recallCounter,Float &rejectionPrecisionCounter,Float &rejectionRecallCounter,
VectorFloat &confusionMatrixCounter,
const UINT numTestSamples);
1203 UINT inputVectorDimensions;
1204 UINT outputVectorDimensions;
1205 UINT predictedClassLabel;
1206 UINT predictedClusterLabel;
1208 UINT predictionModuleIndex;
1209 UINT numTrainingSamples;
1210 UINT numTestSamples;
1213 Float testSquaredError;
1220 Float testRejectionPrecision;
1221 Float testRejectionRecall;
1234 enum PipelineModes{PIPELINE_MODE_NOT_SET=0,CLASSIFICATION_MODE,REGRESSION_MODE,CLUSTER_MODE};
1239 #endif //GRT_GESTURE_RECOGNITION_PIPELINE_HEADER
This is the main base class that all GRT Clustering algorithms should inherit from.
T * getPreProcessingModule(const UINT moduleIndex) const
T * getFeatureExtractionModule(const UINT moduleIndex) const
This is the main base class that all GRT Classification algorithms should inherit from...
This is the main base class that all GRT PostProcessing algorithms should inherit from...
T * getClassifier() const
#define INSERT_AT_END_INDEX
This is the main base class that all GRT PreProcessing algorithms should inherit from.
bool removeRegressifier()
T * getContextModule(const UINT contextLevel, const UINT moduleIndex) const
T * getPostProcessingModule(const UINT moduleIndex) const
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.
T * getRegressifier() const