43 #ifndef GRT_DTW_HEADER
44 #define GRT_DTW_HEADER
46 #include "../../CoreModules/Classifier.h"
47 #include "../../Util/TimeSeriesClassificationSampleTrimmer.h"
63 this->dist = rhs.dist;
80 averageTemplateLength=0;
88 UINT averageTemplateLength;
108 DTW(
bool useScaling=
false,
bool useNullRejection=
false,
double nullRejectionCoeff=3.0,UINT rejectionMode = DTW::TEMPLATE_THRESHOLDS,
bool dtwConstrain=
true,
double radius=0.2,
bool offsetUsingFirstSample=
false,
bool useSmoothing =
false,UINT smoothingFactor = 5);
157 virtual bool predict_(VectorDouble &inputVector);
173 virtual bool reset();
181 virtual bool clear();
291 vector< DTWTemplate >
getModels(){
return templatesBuffer; }
298 bool setModels( vector< DTWTemplate > newTemplates );
333 double d(
int m,
int n,
MatrixDouble &distanceMatrix,
const int M,
const int N);
334 double inline MIN_(
double a,
double b,
double c);
341 void smoothData(VectorDouble &data,UINT smoothFactor,VectorDouble &resultsData);
348 bool loadLegacyModelFromFile( fstream &file );
350 vector< DTWTemplate > templatesBuffer;
351 vector< MatrixDouble > distanceMatrices;
352 vector< vector< IndexDist > > warpPaths;
359 bool useZNormalisation;
360 bool offsetUsingFirstSample;
362 bool constrainWarpingPath;
363 bool trimTrainingData;
365 double zNormConstrainThreshold;
367 double trimThreshold;
368 double maximumTrimPercentage;
370 UINT smoothingFactor;
372 UINT averageTemplateLength;
375 enum DistanceMethods{ABSOLUTE_DIST=0,EUCLIDEAN_DIST,NORM_ABSOLUTE_DIST};
376 enum RejectionModes{TEMPLATE_THRESHOLDS=0,CLASS_LIKELIHOODS,THRESHOLDS_AND_LIKELIHOODS};
382 #endif //GRT_DTW_HEADER
virtual bool saveModelToFile(string filename) const
bool setRejectionMode(UINT rejectionMode)
bool enableZNormalization(bool useZNormalization, bool constrainZNorm=true)
virtual bool loadModelFromFile(string filename)
DTW(bool useScaling=false, bool useNullRejection=false, double nullRejectionCoeff=3.0, UINT rejectionMode=DTW::TEMPLATE_THRESHOLDS, bool dtwConstrain=true, double radius=0.2, bool offsetUsingFirstSample=false, bool useSmoothing=false, UINT smoothingFactor=5)
virtual bool train(ClassificationData trainingData)
bool setOffsetTimeseriesUsingFirstSample(bool offsetUsingFirstSample)
virtual bool deepCopyFrom(const Classifier *classifier)
virtual bool predict(VectorDouble inputVector)
vector< MatrixDouble > getDistanceMatrices()
DTW & operator=(const DTW &rhs)
bool setContrainWarpingPath(bool constrain)
virtual bool loadModelFromFile(fstream &file)
vector< DTWTemplate > getModels()
vector< vector< IndexDist > > getWarpingPaths()
vector< T > getDataAsVector() const
bool setWarpingRadius(double radius)
virtual bool predict_(VectorDouble &inputVector)
virtual bool recomputeNullRejectionThresholds()
vector< VectorDouble > getInputDataBuffer()
bool setModels(vector< DTWTemplate > newTemplates)
bool enableTrimTrainingData(bool trimTrainingData, double trimThreshold, double maximumTrimPercentage)
virtual bool train_(TimeSeriesClassificationData &trainingData)
virtual bool saveModelToFile(fstream &file) const