20019e9dcb52102f1af704663759eff195c43078
[universe.git] / approximer.h
1
2 ////////////////////////////////////////////////////////////////////////////////
3 // This program is free software; you can redistribute it and/or              //
4 // modify it under the terms of the GNU General Public License                //
5 // version 2 as published by the Free Software Foundation.                    //
6 //                                                                            //
7 // This program is distributed in the hope that it will be useful, but        //
8 // WITHOUT ANY WARRANTY; without even the implied warranty of                 //
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          //
10 // General Public License for more details.                                   //
11 //                                                                            //
12 // Written and (C) by François Fleuret                                        //
13 // Contact <francois.fleuret@epfl.ch> for comments & bug reports              //
14 ////////////////////////////////////////////////////////////////////////////////
15
16 #ifndef APPROXIMER_H
17 #define APPROXIMER_H
18
19 #include <iostream>
20 #include <cmath>
21
22 using namespace std;
23
24 #include "misc.h"
25
26 class MappingApproximer {
27   int _max_nb_weak_learners, _nb_weak_learners;
28   int *_indexes;
29   scalar_t *_thresholds;
30   scalar_t *_weights;
31   int _input_size, _nb_samples;
32   scalar_t *_input, *_sample_weights;
33   int *_input_sorted_index;
34 public:
35   scalar_t *_outputs_on_samples;
36   MappingApproximer(int size);
37   ~MappingApproximer();
38   void load(istream &is);
39   void save(ostream &os);
40   void set_learning_input(int input_size, int nb_samples, scalar_t *input, scalar_t *sample_weights);
41   void learn_one_step(scalar_t *target);
42   scalar_t predict(scalar_t *input);
43 };
44
45 void test_approximer();
46
47 #endif