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

fixing templated RapidLib calls

parent bbb3211e
RapidLib @ 86749bf3
Subproject commit 5e0190d65d2204ad2fae48a5120b8c2191c7d106
Subproject commit 86749bf38c0c050dd1c1ccb62c3d3654db4ac66b
......@@ -19,11 +19,11 @@ namespace rapidmix {
/////////////////////////////////////////////////////////////////////// RapidLib specializations
void trainingData2rapidLib (const trainingData &newTrainingData, std::vector<trainingExample<double> > &trainingSet) {
void trainingData2rapidLib (const trainingData &newTrainingData, std::vector<trainingExample> &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<double> tempExample;
trainingExample 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;
......@@ -37,8 +37,8 @@ namespace rapidmix {
/////////////////////////////////////////////////////////////////////// RapidLib classification
template<>
bool machineLearning<classification<double>>::train(const trainingData &newTrainingData) {
std::vector<trainingExample<double> > trainingSet;
bool machineLearning<classification>::train(const trainingData &newTrainingData) {
std::vector<trainingExample> trainingSet;
labels.clear();
for (int i = 0; i < newTrainingData.trainingSet.size(); ++i) {
labels.push_back(newTrainingData.trainingSet[i].label);
......@@ -49,18 +49,18 @@ namespace rapidmix {
/////////////////////////////////////////////////////////////////////// RapidLib regression
template<>
bool machineLearning<regression<double> >::train(const trainingData &newTrainingData) {
std::vector<trainingExample<double> > trainingSet;
bool machineLearning<regression>::train(const trainingData &newTrainingData) {
std::vector<trainingExample> trainingSet;
trainingData2rapidLib(newTrainingData, trainingSet);
return regression::train(trainingSet);
}
/////////////////////////////////////////////////////////////////////// RapidLib seriesClassification
template<>
bool machineLearning<seriesClassification<double> >::train(const trainingData &newTrainingData) {
std::vector<trainingSeries<double> > seriesSet;
bool machineLearning<seriesClassification>::train(const trainingData &newTrainingData) {
std::vector<trainingSeries> seriesSet;
for (int i = 0; i < newTrainingData.trainingSet.size(); ++i) { //each phrase
trainingSeries<double> tempSeries;
trainingSeries 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);
......@@ -71,13 +71,13 @@ namespace rapidmix {
}
template<>
std::string machineLearning<classification<double> >::run(const std::vector<double> &inputVector, const std::string &label) {
std::string machineLearning<classification>::run(const std::vector<double> &inputVector, const std::string &label) {
int classIndex = classification::run(inputVector)[0];
return labels[classIndex];
};
template<>
std::string machineLearning<seriesClassification<double> >::run(const std::vector<std::vector<double> > &inputSeries) {
std::string machineLearning<seriesClassification>::run(const std::vector<std::vector<double> > &inputSeries) {
return seriesClassification::run(inputSeries);
}
......
......@@ -79,13 +79,13 @@ namespace rapidmix {
///// RapidLib
/** @brief static classification using KNN from RapidLib */
typedef machineLearning<classification<double> > staticClassification;
typedef machineLearning<classification> staticClassification;
/** @brief static regression using Neural Networks from RapidLib */
typedef machineLearning<regression<double> > staticRegression;
typedef machineLearning<regression> staticRegression;
/** @brief temporal classification using Dynamic Time Warping from RapidLib */
typedef machineLearning<seriesClassification<double> > dtwTemporalClassification;
typedef machineLearning<seriesClassification> dtwTemporalClassification;
///// XMM
......
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