Commit 6776aaf1 authored by mzed's avatar mzed
Browse files

seriesClassification: check against one label

parent bc883960
......@@ -241,7 +241,11 @@ int main(int argc, const char * argv[]) {
assert(myDTW.run(seriesTwo) == "second series");
//std::cout << myDTW.getCosts()[0] << std::endl;
//std::cout << myDTW.getCosts()[1] << std::endl;
//testing match against single label
assert(myDTW.run(seriesOne, "second series") == 19.325403217417502);
//Training set stats
assert(myDTW.getMaxLength() == 5);
assert(myDTW.getMinLength() == 4);
assert(myDTW.getMaxLength("first series") == 5);
......
......@@ -83,6 +83,23 @@ std::string seriesClassification<T>::run(const std::vector<std::vector<T>> &inpu
return allTrainingSeries[closestSeries].label;
};
template<typename T>
T seriesClassification<T>::run(const std::vector<std::vector<T>> &inputSeries, std::string label) {
int closestSeries = 0;
allCosts.clear();
T lowestCost = std::numeric_limits<T>::max();
for (int i = 0; i < allTrainingSeries.size(); ++i) {
if (allTrainingSeries[i].label == label) {
T currentCost = fastDTW<T>::getCost(inputSeries, allTrainingSeries[i].input, SEARCH_RADIUS);
allCosts.push_back(currentCost);
if (currentCost < lowestCost) {
lowestCost = currentCost;
closestSeries = i;
}
}
}
return lowestCost;
};
template<typename T>
std::vector<T> seriesClassification<T>::getCosts() {
......
......@@ -24,7 +24,10 @@ public:
bool train(const std::vector<trainingSeries<T> > &seriesSet);
void reset();
std::string run(const std::vector<std::vector<T>> &inputSeries);
T run(const std::vector<std::vector<T>> &inputSeries, std::string label);
std::vector<T> getCosts();
int getMinLength();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment