01d8a89fb90cdd68dae225cb542c3b5fbe7e5c1a
[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 // $Id: approximer.h,v 1.6 2006-07-22 12:34:11 fleuret Exp $
17
18 #ifndef APPROXIMER_H
19 #define APPROXIMER_H
20
21 #include <iostream>
22 #include <cmath>
23
24 using namespace std;
25
26 #include "misc.h"
27
28 class MappingApproximer {
29   int _max_nb_weak_learners, _nb_weak_learners;
30   int *_indexes;
31   scalar_t *_thresholds;
32   scalar_t *_weights;
33   int _input_size, _nb_samples;
34   scalar_t *_input, *_sample_weights;
35   int *_input_sorted_index;
36 public:
37   scalar_t *_outputs_on_samples;
38   MappingApproximer(int size);
39   ~MappingApproximer();
40   void load(istream &is);
41   void save(ostream &os);
42   void set_learning_input(int input_size, int nb_samples, scalar_t *input, scalar_t *sample_weights);
43   void learn_one_step(scalar_t *target);
44   scalar_t predict(scalar_t *input);
45 };
46
47 void test_approximer();
48
49 #endif