27 namespace learningmachine {
31 std::ostringstream output;
33 for(
size_t i = 0; i < v.size(); i++) {
34 if(i > 0) output <<
",";
47 this->inputs.push_back(input);
48 this->outputs.push_back(input);
52 this->sampleCount = this->inputs.size();
57 this->checkDomainSize(input);
58 std::cout <<
"Received a prediction sample: " <<
printVector(input) <<
" => ";
59 yarp::sig::Vector output = input;
60 output.resize(this->getCoDomainSize());
61 for(
size_t i = 0; i < output.size(); i++)
62 output[i] += this->sampleCount;
63 std::cout <<
"(" <<
printVector(output) <<
")" << std::endl;
68 this->sampleCount = 0;
71 this->outputs.clear();
75 std::ostringstream buffer;
77 buffer <<
"Training Samples: " << this->sampleCount << std::endl;
78 buffer <<
"Training Iterations: " << this->trainCount << std::endl;
79 buffer <<
"Collected Samples: " << this->inputs.size() << std::endl;
84 bot << this->sampleCount << this->trainCount;
92 bot >> this->trainCount >> this->sampleCount;
virtual void writeBottle(yarp::os::Bottle &bot) const
Writes a serialization of the machine into a bottle.
virtual void train()
Train the learning machine on the examples that have been supplied so far.
void reset()
Forget everything and start over.
std::string getInfo()
Asks the learning machine to return a string containing information on its operation so far.
virtual void feedSample(const yarp::sig::Vector &input, const yarp::sig::Vector &output)
Provide the learning machine with an example of the desired mapping.
Prediction predict(const yarp::sig::Vector &input)
Ask the learning machine to predict the output for a given input.
virtual void readBottle(yarp::os::Bottle &bot)
Unserializes a machine from a bottle.
virtual void writeBottle(yarp::os::Bottle &bot) const
Writes a serialization of the machine into a bottle.
virtual void feedSample(const yarp::sig::Vector &input, const yarp::sig::Vector &output)
Provide the learning machine with an example of the desired mapping.
virtual void readBottle(yarp::os::Bottle &bot)
Unserializes a machine from a bottle.
virtual std::string getInfo()
Asks the learning machine to return a string containing information on its operation so far.
A class that represents a prediction result.
PortablePair< Vector, Vector > Prediction
std::string printVector(const yarp::sig::Vector &v)
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.