2 ///////////////////////////////////////////////////////////////////////////
3 // This program is free software: you can redistribute it and/or modify //
4 // it under the terms of the version 3 of the GNU General Public License //
5 // as published by the Free Software Foundation. //
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. //
12 // You should have received a copy of the GNU General Public License //
13 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
15 // Written by Francois Fleuret //
16 // (C) Idiap Research Institute //
18 // Contact <francois.fleuret@idiap.ch> for comments & bug reports //
19 ///////////////////////////////////////////////////////////////////////////
23 A LossMachine provides all the methods necessary to do boosting with
24 a certain loss. Note that only the LOSS_EXPONENTIAL has been really
25 tested. Using the others may result in unexpected effects.
29 #ifndef LOSS_MACHINE_H
30 #define LOSS_MACHINE_H
33 #include "sample_set.h"
39 LossMachine(int loss_type);
41 void get_loss_derivatives(SampleSet *samples,
43 scalar_t *derivatives);
45 scalar_t loss(SampleSet *samples, scalar_t *responses);
47 scalar_t optimal_weight(SampleSet *sample_set,
48 scalar_t *weak_learner_responses,
49 scalar_t *current_responses);
51 /* This method returns in sample_nb_occurences[k] the number of time
52 the example k was sampled, and in sample_responses[k] the
53 consistent response so that the overall loss remains the same. If
54 allow_duplicates is set to 1, all samples will have an identical
55 response (i.e. weight), but some may have more than one
56 occurence. On the contrary, if allow_duplicates is 0, samples
57 will all have only one occurence (or zero) but the responses may
58 vary to account for the multiple sampling. */
60 void subsample(int nb, scalar_t *labels, scalar_t *responses,
61 int nb_to_sample, int *sample_nb_occurences, scalar_t *sample_responses,
62 int allow_duplicates);