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

adjusted to no default set. Moved template stuff into the ML class.

parent a593c2bc
......@@ -56,6 +56,12 @@ bool machineLearning<seriesClassification>::train(const trainingData &newTrainin
return seriesClassification::trainLabel(seriesSet);
}
template<>
bool machineLearning<rapidGVF>::train(const trainingData &newTrainingData) {
return rapidGVF::train(newTrainingData);
}
///Generic train
template <class MachineLearningModule>
bool machineLearning<MachineLearningModule>::train(const trainingData &newTrainingData) {
......
......@@ -21,12 +21,6 @@ rapidGVF::~rapidGVF()
this->currentGesture = NULL;
}
template<>
bool rapidmix::machineLearning<rapidGVF>::train(const trainingData &newTrainingData) {
return rapidGVF::train(newTrainingData);
}
bool rapidGVF::train(const rapidmix::trainingData &newTrainingData) {
if (newTrainingData.trainingSet.size() < 1) {
......@@ -46,7 +40,7 @@ bool rapidGVF::train(const rapidmix::trainingData &newTrainingData) {
//Go through every phrase
for (int h = 1; h < newTrainingData.trainingSet.size(); ++h) {
for (int h = 0; h < newTrainingData.trainingSet.size(); ++h) { //FIXME: I changed this because the default set is gone. -MZ
this->gvf->startGesture();
for (int i = 0; i < newTrainingData.trainingSet[h].elements.size(); ++i) {
......@@ -61,13 +55,7 @@ bool rapidGVF::train(const rapidmix::trainingData &newTrainingData) {
return true;
}
template<>
std::vector<double> rapidmix::machineLearning<rapidGVF>::run(const std::vector<double> &inputVector) {
return rapidGVF::process(inputVector);
}
std::vector<double> rapidGVF::process(const std::vector<double> &inputVector){
std::vector<double> rapidGVF::run(const std::vector<double> &inputVector){
if (inputVector.size() == 0) {
......
......@@ -15,19 +15,18 @@
namespace rapidmix { class trainingData; }
/**
/**
* @brief This class is an adapter for the GVF library from Baptiste Caramiaux
*/
class rapidGVF {
public:
public:
rapidGVF();
~rapidGVF();
bool train(const rapidmix::trainingData &newTrainingData);
std::vector<double> process(const std::vector<double> &inputVector);
std::vector<double> run(const std::vector<double> &inputVector);
//TODO: needs a "reset" message
protected:
GVF * gvf;
......
......@@ -129,7 +129,7 @@ SCENARIO("Test GVF Regression", "[machineLearning]")
myData.stopRecording();
// Train
gvf.train(myData);
REQUIRE(gvf.train(myData) == true);
// Set first gesture (or a fragment of it)
std::vector<double> outcomes;
......@@ -138,11 +138,11 @@ SCENARIO("Test GVF Regression", "[machineLearning]")
{
THEN("follows the the gesture (first) and confirm it is the likeliestGesture and likelihoods reasonable")
{
outcomes = gvf.process(inputs = { 3.0, 0.8 });
outcomes = gvf.process({ 2.0, 0.9 });
outcomes = gvf.process({ 1.0, 1.0 });
outcomes = gvf.process({ 0.4, 1.2 });
outcomes = gvf.process({ 0.2, 1.4 });
outcomes = gvf.run(inputs = { 3.0, 0.8 });
outcomes = gvf.run({ 2.0, 0.9 });
outcomes = gvf.run({ 1.0, 1.0 });
outcomes = gvf.run({ 0.4, 1.2 });
outcomes = gvf.run({ 0.2, 1.4 });
// The assumtion for the test is that the outcome of the last segment of the test gesture must converge
REQUIRE(outcomes[0] == 0); // outcomes[0] - likeliestGesture must be equal to first gesture '0'
......
......@@ -41,6 +41,18 @@
311BA3241EDC7BA800244DAC /* DnB-loop-175BPM.wav in CopyFiles */ = {isa = PBXBuildFile; fileRef = 311BA3231EDC7BA400244DAC /* DnB-loop-175BPM.wav */; };
311BA3251EDCE80B00244DAC /* jsoncpp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5E081ED8450E00E9FAFA /* jsoncpp.cpp */; };
31A8F1971F4ECF3300CA8CEC /* rapidXMM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31A8F1941F4ECD1200CA8CEC /* rapidXMM.cpp */; };
BE5733061F505ECC0063F4D1 /* machineLearning.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5EBE1ED8459300E9FAFA /* machineLearning.cpp */; };
BE5733071F505F190063F4D1 /* rapidGVF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BE2E7351EE56F4F00722712 /* rapidGVF.cpp */; };
BE5733081F505F310063F4D1 /* GVF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BE2E72F1EE56E6D00722712 /* GVF.cpp */; };
BE5733091F505F7F0063F4D1 /* seriesClassification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE9286531EF01A23006847CF /* seriesClassification.cpp */; };
BE57330A1F505F870063F4D1 /* regression.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5DF91ED8450E00E9FAFA /* regression.cpp */; };
BE57330B1F505F920063F4D1 /* dtw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE9286571EF01C45006847CF /* dtw.cpp */; };
BE57330C1F505F9B0063F4D1 /* neuralNetwork.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5DF71ED8450E00E9FAFA /* neuralNetwork.cpp */; };
BE57330D1F505FAA0063F4D1 /* classification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5DEA1ED8450E00E9FAFA /* classification.cpp */; };
BE57330E1F505FAD0063F4D1 /* modelSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5DF51ED8450E00E9FAFA /* modelSet.cpp */; };
BE57330F1F505FBD0063F4D1 /* knnClassification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5DF31ED8450E00E9FAFA /* knnClassification.cpp */; };
BE5733101F505FC80063F4D1 /* svmClassification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE92864E1EF017E2006847CF /* svmClassification.cpp */; };
BE5733111F505FDC0063F4D1 /* libsvm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5F0F1EDD74BC00E9FAFA /* libsvm.cpp */; };
BE9286491EF015AE006847CF /* test_signalProcessing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5EE31ED8480D00E9FAFA /* test_signalProcessing.cpp */; };
BE92864C1EF015E7006847CF /* rapidStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE92864A1EF015E7006847CF /* rapidStream.cpp */; };
BE92864D1EF01622006847CF /* rapidStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE92864A1EF015E7006847CF /* rapidStream.cpp */; };
......@@ -1124,12 +1136,22 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BE5733101F505FC80063F4D1 /* svmClassification.cpp in Sources */,
BE57330F1F505FBD0063F4D1 /* knnClassification.cpp in Sources */,
BE57330E1F505FAD0063F4D1 /* modelSet.cpp in Sources */,
BE57330D1F505FAA0063F4D1 /* classification.cpp in Sources */,
BE57330C1F505F9B0063F4D1 /* neuralNetwork.cpp in Sources */,
BE57330A1F505F870063F4D1 /* regression.cpp in Sources */,
BE57330B1F505F920063F4D1 /* dtw.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 */,
BEA7B7211EDD97130003E84B /* test_gvf.cpp in Sources */,
0BA41BAD1EE6E0ED00B74667 /* trainingData.cpp in Sources */,
BE5733061F505ECC0063F4D1 /* machineLearning.cpp in Sources */,
BE5733111F505FDC0063F4D1 /* libsvm.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -1150,6 +1172,8 @@
BEA7B7171EDD7B7E0003E84B /* jsoncpp.cpp in Sources */,
BE9286511EF01801006847CF /* svmClassification.cpp in Sources */,
BE9286521EF01823006847CF /* libsvm.cpp in Sources */,
BE5733071F505F190063F4D1 /* rapidGVF.cpp in Sources */,
BE5733081F505F310063F4D1 /* GVF.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