23#include <yarp/math/Math.h> 
   29using namespace yarp::math;
 
   34namespace learningmachine {
 
   39    this->sampleCount = 0;
 
 
   50    B(other.B), W(other.W), lambda(other.lambda) {
 
 
   57    if(
this == &other) 
return *
this; 
 
   59    this->IFixedSizeLearner::operator=(other);
 
   60    this->sampleCount = other.sampleCount;
 
   65    this->lambda = other.lambda;
 
 
   77    this->B = this->B + 
outerprod(output, input);
 
 
   92    yarp::sig::Vector output = (this->W * input);
 
 
   98    this->sampleCount = 0;
 
 
  105    std::ostringstream buffer;
 
  107    buffer << 
"Lambda: " << this->
getLambda() << 
" | ";
 
  108    buffer << 
"Sample Count: " << this->sampleCount << std::endl;
 
 
  118    std::ostringstream buffer;
 
  120    buffer << 
"  lambda val            Regularization parameter lambda" << std::endl;
 
 
  125    bot << this->R << this->B << this->W << this->lambda << this->sampleCount;
 
 
  133    bot >> this->sampleCount >> this->lambda >> this->W >> this->B >> this->R;
 
 
  151        throw std::runtime_error(
"Regularization parameter lamdba has to be larger than 0");
 
 
  164    if(config.find(
"lambda").isFloat64() || config.find(
"lambda").isInt32()) {
 
  165        this->
setLambda(config.find(
"lambda").asFloat64());
 
 
An generalized interface for a learning machine with a fixed domain and codomain size.
 
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 bool checkDomainSize(const yarp::sig::Vector &input)
Checks whether the input is of the desired dimensionality.
 
unsigned int getCoDomainSize() const
Returns the size (dimensionality) of the output domain (codomain).
 
virtual std::string getInfo()
Asks the learning machine to return a string containing information on its operation so far.
 
virtual void setCoDomainSize(unsigned int size)
Mutator for the codomain size.
 
virtual bool configure(yarp::os::Searchable &config)
Change parameters.
 
virtual void setDomainSize(unsigned int size)
Mutator for the domain size.
 
virtual std::string getConfigHelp()
Asks the learning machine to return a string containing the list of configuration options that it sup...
 
unsigned int getDomainSize() const
Returns the size (dimensionality) of the input domain.
 
void setName(const std::string &name)
Set the name of this machine learning technique.
 
A class that represents a prediction result.
 
Recursive Regularized Least Squares (a.k.a.
 
void setCoDomainSize(unsigned int size)
Mutator for the codomain size.
 
void reset()
Forget everything and start over.
 
virtual std::string getInfo()
Asks the learning machine to return a string containing information on its operation so far.
 
virtual void readBottle(yarp::os::Bottle &bot)
Unserializes a machine from a bottle.
 
virtual Prediction predict(const yarp::sig::Vector &input)
Ask the learning machine to predict the output for a given input.
 
virtual std::string getConfigHelp()
Asks the learning machine to return a string containing the list of configuration options that it sup...
 
void setDomainSize(unsigned int size)
Mutator for the domain size.
 
virtual void writeBottle(yarp::os::Bottle &bot)
 
virtual void train()
Train the learning machine on the examples that have been supplied so far.
 
virtual ~RLSLearner()
Destructor.
 
void setLambda(double l)
Sets the regularization parameter \lambda to a specified value.
 
RLSLearner & operator=(const RLSLearner &other)
Assignment operator.
 
RLSLearner(unsigned int dom=1, unsigned int cod=1, double lambda=1.0)
Constructor.
 
double getLambda()
Accessor for the regularization parameter \lambda.
 
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 bool configure(yarp::os::Searchable &config)
Change parameters.
 
void cholupdate(yarp::sig::Matrix &R, const yarp::sig::Vector &x, yarp::sig::Vector &c, yarp::sig::Vector &s, yarp::sig::Matrix &Z, const yarp::sig::Vector &y, yarp::sig::Vector &rho, bool rtrans=0, bool ztrans=0)
Perform a rank-1 update to a Cholesky factor, while updating additional vectors using the used Given'...
 
yarp::sig::Matrix outerprod(const yarp::sig::Vector &v1, const yarp::sig::Vector &v2)
Computes the outer product of two vectors.
 
void cholsolve(const yarp::sig::Matrix &R, const yarp::sig::Matrix &B, yarp::sig::Matrix &X)
Solves a system A*x=b for multiple row vectors in B using a precomputed Cholesky factor R.
 
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.