iCub-main
RLSLearner.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2011 RobotCub Consortium, European Commission FP6 Project IST-004370
3  * author: Arjan Gijsberts
4  * email: arjan.gijsberts@iit.it
5  * website: www.robotcub.org
6  * Permission is granted to copy, distribute, and/or modify this program
7  * under the terms of the GNU General Public License, version 2 or any
8  * later version published by the Free Software Foundation.
9  *
10  * A copy of the license can be found at
11  * http://www.robotcub.org/icub/license/gpl.txt
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16  * Public License for more details
17  */
18 
19 #ifndef LM_RLSLEARNER__
20 #define LM_RLSLEARNER__
21 
22 #include <yarp/sig/Matrix.h>
23 
25 
26 
27 namespace iCub {
28 namespace learningmachine {
29 
30 
46 class RLSLearner : public IFixedSizeLearner {
47 private:
51  yarp::sig::Matrix R;
52 
56  yarp::sig::Matrix B;
57 
61  yarp::sig::Matrix W;
62 
66  int sampleCount;
67 
71  double lambda;
72 
73 public:
81  RLSLearner(unsigned int dom = 1, unsigned int cod = 1, double lambda = 1.0);
82 
86  RLSLearner(const RLSLearner& other);
87 
91  virtual ~RLSLearner();
92 
96  RLSLearner& operator=(const RLSLearner& other);
97 
98  /*
99  * Inherited from IMachineLearner.
100  */
101  virtual void feedSample(const yarp::sig::Vector& input, const yarp::sig::Vector& output);
102 
103  /*
104  * Inherited from IMachineLearner.
105  */
106  virtual void train();
107 
108  /*
109  * Inherited from IMachineLearner.
110  */
111  virtual Prediction predict(const yarp::sig::Vector& input);
112 
113  /*
114  * Inherited from IMachineLearner.
115  */
116  void reset();
117 
118  /*
119  * Inherited from IMachineLearner.
120  */
122  return new RLSLearner(*this);
123  }
124 
125  /*
126  * Inherited from IMachineLearner.
127  */
128  virtual std::string getInfo();
129 
130  /*
131  * Inherited from IMachineLearner.
132  */
133  virtual std::string getConfigHelp();
134 
135  /*
136  * Inherited from IMachineLearner.
137  */
138  virtual void writeBottle(yarp::os::Bottle& bot);
139 
140  /*
141  * Inherited from IMachineLearner.
142  */
143  virtual void readBottle(yarp::os::Bottle& bot);
144 
145  /*
146  * Inherited from IFixedSizeLearner.
147  */
148  void setDomainSize(unsigned int size);
149 
150  /*
151  * Inherited from IFixedSizeLearner.
152  */
153  void setCoDomainSize(unsigned int size);
154 
161  void setLambda(double l);
162 
168  double getLambda();
169 
170  /*
171  * Inherited from IMachineLearner.
172  */
173  virtual bool configure(yarp::os::Searchable& config);
174 };
175 
176 } // learningmachine
177 } // iCub
178 #endif
An generalized interface for a learning machine with a fixed domain and codomain size.
A class that represents a prediction result.
Definition: Prediction.h:44
Recursive Regularized Least Squares (a.k.a.
Definition: RLSLearner.h:46
void setCoDomainSize(unsigned int size)
Mutator for the codomain size.
Definition: RLSLearner.cpp:141
void reset()
Forget everything and start over.
Definition: RLSLearner.cpp:97
RLSLearner * clone()
Asks the learning machine to return a clone of its type.
Definition: RLSLearner.h:121
virtual std::string getInfo()
Asks the learning machine to return a string containing information on its operation so far.
Definition: RLSLearner.cpp:104
virtual void readBottle(yarp::os::Bottle &bot)
Unserializes a machine from a bottle.
Definition: RLSLearner.cpp:130
virtual Prediction predict(const yarp::sig::Vector &input)
Ask the learning machine to predict the output for a given input.
Definition: RLSLearner.cpp:89
virtual std::string getConfigHelp()
Asks the learning machine to return a string containing the list of configuration options that it sup...
Definition: RLSLearner.cpp:117
void setDomainSize(unsigned int size)
Mutator for the domain size.
Definition: RLSLearner.cpp:136
virtual void writeBottle(yarp::os::Bottle &bot)
Definition: RLSLearner.cpp:124
virtual void train()
Train the learning machine on the examples that have been supplied so far.
Definition: RLSLearner.cpp:85
virtual ~RLSLearner()
Destructor.
Definition: RLSLearner.cpp:53
void setLambda(double l)
Sets the regularization parameter \lambda to a specified value.
Definition: RLSLearner.cpp:146
RLSLearner & operator=(const RLSLearner &other)
Assignment operator.
Definition: RLSLearner.cpp:56
RLSLearner(unsigned int dom=1, unsigned int cod=1, double lambda=1.0)
Constructor.
Definition: RLSLearner.cpp:37
double getLambda()
Accessor for the regularization parameter \lambda.
Definition: RLSLearner.cpp:155
virtual void feedSample(const yarp::sig::Vector &input, const yarp::sig::Vector &output)
Provide the learning machine with an example of the desired mapping.
Definition: RLSLearner.cpp:70
virtual bool configure(yarp::os::Searchable &config)
Change parameters.
Definition: RLSLearner.cpp:160
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.