RapidLib  v2.2.0
A simple library for interactive machine learning
seriesClassification.h
Go to the documentation of this file.
1 
10 #ifndef SERIESCLASSIFICATION_H
11 #define SERIESCLASSIFICATION_H
12 
13 #include <vector>
14 #include <string>
15 #include <map>
16 #include "fastDTW.h"
17 #include "trainingExample.h"
18 
24 template<typename T>
26 {
27 public:
28 
32 
36  bool train(const std::vector<trainingSeriesTemplate<T> > &seriesSet);
37 
39  void reset();
40 
45  std::string run(const std::vector<std::vector<T> > &inputSeries);
46 
52  T run(const std::vector<std::vector<T> >& inputSeries, std::string label);
53 
58  std::string runParallel(const std::vector<std::vector<T> >& inputSeries);
59 
65  T runParallel(const std::vector<std::vector<T> > &inputSeries, std::string label);
66 
71  std::string runContinuous(const std::vector<T> &inputVector);
72 
76  std::vector<T> getCosts() const;
77 
81  std::size_t getMinLength() const;
82 
87  std::size_t getMinLength(std::string label) const;
88 
92  std::size_t getMaxLength() const;
93 
98  std::size_t getMaxLength(std::string label) const;
99 
101  template<typename TT>
102  struct minMax {
103  TT min;
104  TT max;
105  };
106 
111  minMax<T> calculateCosts(std::string label) const;
112 
118  minMax<T> calculateCosts(std::string label1, std::string label2) const;
119 
120 private:
121  std::vector<trainingSeriesTemplate<T> > allTrainingSeries;
122  size_t vectorLength;
123  std::vector<T> allCosts;
124  size_t maxLength;
125  size_t minLength;
126  std::map<std::string, minMax<size_t> > lengthsPerLabel;
127  bool isTraining { false };
128 
129  std::vector<std::vector<T> > seriesBuffer;
130  int hopSize {1};
131  int counter {};
132 
133  size_t findClosestSeries() const;
134  void runThread(const std::vector<std::vector<T>> &inputSeries, std::size_t i);
135 };
136 
137 namespace rapidLib
138 {
139 //This is here to keep the old API working
142 }
143 
144 #endif
Definition: seriesClassification.h:26
void reset()
Definition: seriesClassification.cpp:85
std::vector< T > getCosts() const
Definition: seriesClassification.cpp:260
minMax< T > calculateCosts(std::string label) const
Definition: seriesClassification.cpp:296
std::string runContinuous(const std::vector< T > &inputVector)
Definition: seriesClassification.cpp:241
std::string runParallel(const std::vector< std::vector< T > > &inputSeries)
Definition: seriesClassification.cpp:158
std::size_t getMaxLength() const
Definition: seriesClassification.cpp:281
seriesClassificationTemplate()
Definition: seriesClassification.cpp:25
~seriesClassificationTemplate()
Definition: seriesClassification.cpp:28
std::string run(const std::vector< std::vector< T > > &inputSeries)
std::size_t getMinLength() const
Definition: seriesClassification.cpp:266
bool train(const std::vector< trainingSeriesTemplate< T > > &seriesSet)
Definition: seriesClassification.cpp:31
Definition: classification.h:75
Definition: seriesClassification.h:102
TT max
Definition: seriesClassification.h:104
TT min
Definition: seriesClassification.h:103
Definition: trainingExample.h:34