19#ifndef LM_PREDICTION__
20#define LM_PREDICTION__
25#include <yarp/os/ConnectionReader.h>
26#include <yarp/os/ConnectionWriter.h>
27#include <yarp/os/Portable.h>
28#include <yarp/sig/Vector.h>
31namespace learningmachine {
98 return this->prediction.size();
138 this->varianceSet = (
variance.size() > 0);
156 std::string
out = this->prediction.toString().c_str();
158 out += std::string(
" +/- ") + this->variance.toString().c_str();
166 bool write(yarp::os::ConnectionWriter& connection)
const {
168 connection.appendInt32(BOTTLE_TAG_LIST);
169 connection.appendInt32(2);
171 bool ok = this->prediction.write(connection);
173 ok = this->variance.write(connection);
177 connection.convertTextMode();
186 bool read(yarp::os::ConnectionReader& connection) {
188 connection.convertTextMode();
190 int header = connection.expectInt32();
191 if(header != BOTTLE_TAG_LIST) {
195 int len = connection.expectInt32();
200 bool ok = this->prediction.read(connection);
202 ok = this->variance.read(connection);
204 this->varianceSet = (this->variance.size() > 0);
212 this->prediction.onCompletion();
213 this->variance.onCompletion();
A class that represents a prediction result.
Prediction(const yarp::sig::Vector &prediction, const yarp::sig::Vector &variance)
Constructor for expected value prediction with predictive variance.
std::string toString()
Returns a string represenation of the prediction.
unsigned int size()
Returns the size of the prediction.
yarp::sig::Vector getVariance()
Accessor for the variance of the prediction.
virtual void onCompletion()
yarp::sig::Vector prediction
Expected value of the prediction.
Prediction(const yarp::sig::Vector &prediction)
Constructor for expected value prediction without predictive variance.
bool varianceSet
Indicator whether prediction variance is available.
bool write(yarp::os::ConnectionWriter &connection) const
yarp::sig::Vector variance
Optional variance of the prediction, measured as a unit standard deviation.
void setPrediction(const yarp::sig::Vector &prediction)
Mutator for the expected value of the prediction.
void setVariance(const yarp::sig::Vector &variance)
Mutator for the variance of the prediction.
Prediction()
Empty constructor.
bool hasVariance()
Indicator whether the prediction contains a predicted variance.
bool read(yarp::os::ConnectionReader &connection)
yarp::sig::Vector getPrediction()
Accessor for the expected value of the prediction.
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.