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

Adding function to add element with no output to trainingData

parent 0dbadab5
......@@ -36,7 +36,7 @@ public:
//* this function becomes specialized in the implementation */
bool train(const trainingData &newTrainingData);
// Could overload this, or specialize, or both
//* this function is not being specialized
std::vector<double> run(const std::vector<double> &inputVector) {
return MachineLearningModule::run(inputVector);
}
......
......@@ -49,6 +49,15 @@ uint32_t trainingData::addElement(std::vector<double>input, std::vector<double>
return newElement.uniqueId;
}
uint32_t trainingData::addElement(std::vector<double>input) {
element newElement;
newElement.uniqueId = assignCurrentId();
newElement.input = input;
newElement.timeStamp = NULL;
trainingSet[targetPhrase].elements.push_back(newElement);
return newElement.uniqueId;
}
void trainingData::stopRecording() {
targetPhrase = 0; //direct elements to default phrase
......
......@@ -45,9 +45,12 @@ public:
//* Create new phrase, with a label, that can be recorded into. Returns phrase id */
uint32_t startRecording(std::string label);
//* Add an element to the phrase that is recording, or to the default phrase if recording is stopped. Returns phrase id. */
//* Add an element with input and output to the phrase that is recording, or to the default phrase if recording is stopped. Returns phrase id. */
uint32_t addElement(std::vector<double>input, std::vector<double> output);
//* Add an element with just input to the phrase that is recording, or to the default phrase if recording is stopped. Returns phrase id. */
uint32_t addElement(std::vector<double>input);
void stopRecording();
std::vector<std::string> getColumnNames();
......
......@@ -89,44 +89,43 @@ SCENARIO("Test GVF Regression", "[machineLearning]")
// Record first gesture
myData.startRecording();
std::vector<double> inputs = { 4.0, 0.7 };
std::vector<double> outputs = { };
myData.addElement(inputs, outputs);
myData.addElement(inputs);
inputs = { 3.0, 0.8 };
myData.addElement(inputs, outputs);
myData.addElement(inputs);
inputs = { 2.0, 0.9 };
myData.addElement(inputs, outputs);
myData.addElement(inputs);
inputs = { 1.0, 1.0 };
myData.addElement(inputs, outputs);
myData.addElement(inputs);
inputs = { 0.4, 1.2 };
myData.addElement(inputs, outputs);
myData.addElement(inputs);
inputs = { 0.2, 1.4 };
myData.addElement(inputs, outputs);
myData.addElement(inputs);
myData.stopRecording();
// Record reverse of first gesture
myData.startRecording();
inputs = { 0.2, 1.4 };
myData.addElement(inputs, outputs);
myData.addElement(inputs);
inputs = { 0.4, 1.2 };
myData.addElement(inputs, outputs);
myData.addElement(inputs);
inputs = { 1.0, 1.0 };
myData.addElement(inputs, outputs);
myData.addElement(inputs);
inputs = { 2.0, 0.9 };
myData.addElement(inputs, outputs);
myData.addElement(inputs);
inputs = { 3.0, 0.8 };
myData.addElement(inputs, outputs);
myData.addElement(inputs);
inputs = { 4.0, 0.7 };
myData.addElement(inputs, outputs);
myData.addElement(inputs);
myData.stopRecording();
// Train
......
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