Commit de3b2f64 authored by Michael Zbyszyński's avatar Michael Zbyszyński
Browse files

RapidLib classes are now templates.

parent b85907a7
RapidLib @ bc883960
Subproject commit 337e093e00a8ed4aebd6b33bbd390aff6d1458b5
Subproject commit bc88396015050bf1cb185aa176e13be013148e91
......@@ -10,11 +10,11 @@
namespace rapidmix {
void trainingData2rapidLib (const trainingData &newTrainingData, std::vector<trainingExample> &trainingSet) {
void trainingData2rapidLib (const trainingData &newTrainingData, std::vector<trainingExample<double> > &trainingSet) {
for (int h = 0; h < newTrainingData.trainingSet.size(); ++h) { //Go through every phrase
for (int i = 0; i < newTrainingData.trainingSet[h].elements.size(); ++i) { //...and every element
trainingExample tempExample;
trainingExample<double> tempExample;
tempExample.input = newTrainingData.trainingSet[h].elements[i].input;
if (newTrainingData.trainingSet[h].elements[i].output.size() > 0) {
tempExample.output = newTrainingData.trainingSet[h].elements[i].output;
......@@ -27,8 +27,8 @@ namespace rapidmix {
};
template<>
bool machineLearning<classification>::train(const trainingData &newTrainingData) {
std::vector<trainingExample> trainingSet;
bool machineLearning<classification<double>>::train(const trainingData &newTrainingData) {
std::vector<trainingExample<double> > trainingSet;
labels.clear();
for (int i = 0; i < newTrainingData.trainingSet.size(); ++i) {
labels.push_back(newTrainingData.trainingSet[i].label);
......@@ -38,24 +38,24 @@ namespace rapidmix {
}
template<>
bool machineLearning<regression>::train(const trainingData &newTrainingData) {
std::vector<trainingExample> trainingSet;
bool machineLearning<regression<double> >::train(const trainingData &newTrainingData) {
std::vector<trainingExample<double> > trainingSet;
trainingData2rapidLib(newTrainingData, trainingSet);
return regression::train(trainingSet);
}
template<>
bool machineLearning<seriesClassification>::train(const trainingData &newTrainingData) {
std::vector<trainingSeries> seriesSet;
bool machineLearning<seriesClassification<double> >::train(const trainingData &newTrainingData) {
std::vector<trainingSeries<double> > seriesSet;
for (int i = 0; i < newTrainingData.trainingSet.size(); ++i) { //each phrase
trainingSeries tempSeries;
trainingSeries<double> tempSeries;
tempSeries.label = newTrainingData.trainingSet[i].label;
for (int j = 0; j < newTrainingData.trainingSet[i].elements.size(); ++j) { //each element
tempSeries.input.push_back(newTrainingData.trainingSet[i].elements[j].input);
}
seriesSet.push_back(tempSeries);
}
return seriesClassification::trainLabel(seriesSet);
return seriesClassification::train(seriesSet);
}
template<>
......@@ -71,14 +71,14 @@ namespace rapidmix {
}
template<>
std::string machineLearning<classification>::run(const std::vector<double> &inputVector, const std::string &label) {
std::string machineLearning<classification<double> >::run(const std::vector<double> &inputVector, const std::string &label) {
int classIndex = classification::run(inputVector)[0];
return labels[classIndex];
};
template<>
std::string machineLearning<seriesClassification>::run(const std::vector<std::vector<double> > &inputSeries) {
return seriesClassification::runLabel(inputSeries);
std::string machineLearning<seriesClassification<double> >::run(const std::vector<std::vector<double> > &inputSeries) {
return seriesClassification::run(inputSeries);
}
}
\ No newline at end of file
......@@ -79,13 +79,13 @@ namespace rapidmix {
///// RapidLib
/** @brief static classification using KNN from RapidLib */
typedef machineLearning<classification> staticClassification;
typedef machineLearning<classification<double> > staticClassification;
/** @brief static regression using Neural Networks from RapidLib */
typedef machineLearning<regression> staticRegression;
typedef machineLearning<regression<double> > staticRegression;
/** @brief temporal classification using Dynamic Time Warping from RapidLib */
typedef machineLearning<seriesClassification> dtwTemporalClassification;
typedef machineLearning<seriesClassification<double> > dtwTemporalClassification;
///// XMM
......
......@@ -25,7 +25,7 @@ namespace rapidmix {
typedef maxiFFT FFT;
typedef maxiMFCC MFCC;
typedef rapidStream rapidStream; //MZ: Best... typedef... EVER!
typedef rapidStream<double> rapidStream;
typedef pipoHost pipoHost;
typedef pipoStreamAttributes pipoStreamAttributes;
......
......@@ -75,6 +75,12 @@
BEA7B71E1EDD963E0003E84B /* maximilian.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5A1F1ED8450C00E9FAFA /* maximilian.cpp */; };
BEA7B7201EDD96AC0003E84B /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 311BA3201EDC7B2400244DAC /* Accelerate.framework */; };
BEA7B7211EDD97130003E84B /* test_gvf.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5EDE1ED8480D00E9FAFA /* test_gvf.cpp */; };
BEF47B1B1F7A74E5005B0C35 /* searchWindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEF47B191F7A74E5005B0C35 /* searchWindow.cpp */; };
BEF47B1E1F7A74EE005B0C35 /* fastDTW.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEF47B1C1F7A74EE005B0C35 /* fastDTW.cpp */; };
BEF47B211F7A74FC005B0C35 /* warpPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEF47B1F1F7A74FC005B0C35 /* warpPath.cpp */; };
BEF47B221F7A8685005B0C35 /* fastDTW.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEF47B1C1F7A74EE005B0C35 /* fastDTW.cpp */; };
BEF47B231F7A868B005B0C35 /* warpPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEF47B1F1F7A74FC005B0C35 /* warpPath.cpp */; };
BEF47B241F7A8693005B0C35 /* searchWindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEF47B191F7A74E5005B0C35 /* searchWindow.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -356,6 +362,12 @@
BE9286541EF01A23006847CF /* seriesClassification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = seriesClassification.h; sourceTree = "<group>"; };
BE9286571EF01C45006847CF /* dtw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dtw.cpp; sourceTree = "<group>"; };
BE9286581EF01C45006847CF /* dtw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dtw.h; sourceTree = "<group>"; };
BEF47B191F7A74E5005B0C35 /* searchWindow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = searchWindow.cpp; sourceTree = "<group>"; };
BEF47B1A1F7A74E5005B0C35 /* searchWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = searchWindow.h; sourceTree = "<group>"; };
BEF47B1C1F7A74EE005B0C35 /* fastDTW.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fastDTW.cpp; sourceTree = "<group>"; };
BEF47B1D1F7A74EE005B0C35 /* fastDTW.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fastDTW.h; sourceTree = "<group>"; };
BEF47B1F1F7A74FC005B0C35 /* warpPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = warpPath.cpp; sourceTree = "<group>"; };
BEF47B201F7A74FC005B0C35 /* warpPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = warpPath.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -696,6 +708,12 @@
BE2C5DE81ED8450E00E9FAFA /* src */ = {
isa = PBXGroup;
children = (
BEF47B1F1F7A74FC005B0C35 /* warpPath.cpp */,
BEF47B201F7A74FC005B0C35 /* warpPath.h */,
BEF47B1C1F7A74EE005B0C35 /* fastDTW.cpp */,
BEF47B1D1F7A74EE005B0C35 /* fastDTW.h */,
BEF47B191F7A74E5005B0C35 /* searchWindow.cpp */,
BEF47B1A1F7A74E5005B0C35 /* searchWindow.h */,
BE9286571EF01C45006847CF /* dtw.cpp */,
BE9286581EF01C45006847CF /* dtw.h */,
BE9286531EF01A23006847CF /* seriesClassification.cpp */,
......@@ -1143,11 +1161,14 @@
BE57330C1F505F9B0063F4D1 /* neuralNetwork.cpp in Sources */,
BE57330A1F505F870063F4D1 /* regression.cpp in Sources */,
BE57330B1F505F920063F4D1 /* dtw.cpp in Sources */,
BEF47B1B1F7A74E5005B0C35 /* searchWindow.cpp in Sources */,
BE92864C1EF015E7006847CF /* rapidStream.cpp in Sources */,
BE5733091F505F7F0063F4D1 /* seriesClassification.cpp in Sources */,
0BA41BAE1EE6E10A00B74667 /* jsoncpp.cpp in Sources */,
0BE2E7381EE56F5800722712 /* GVF.cpp in Sources */,
0BE2E7371EE56F4F00722712 /* rapidGVF.cpp in Sources */,
BEF47B1E1F7A74EE005B0C35 /* fastDTW.cpp in Sources */,
BEF47B211F7A74FC005B0C35 /* warpPath.cpp in Sources */,
BEA7B7211EDD97130003E84B /* test_gvf.cpp in Sources */,
0BA41BAD1EE6E0ED00B74667 /* trainingData.cpp in Sources */,
BE5733061F505ECC0063F4D1 /* machineLearning.cpp in Sources */,
......@@ -1174,6 +1195,9 @@
BE9286521EF01823006847CF /* libsvm.cpp in Sources */,
BE5733071F505F190063F4D1 /* rapidGVF.cpp in Sources */,
BE5733081F505F310063F4D1 /* GVF.cpp in Sources */,
BEF47B231F7A868B005B0C35 /* warpPath.cpp in Sources */,
BEF47B241F7A8693005B0C35 /* searchWindow.cpp in Sources */,
BEF47B221F7A8685005B0C35 /* fastDTW.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
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