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 ///////////////////////////////////////////////////////////////////////////
21 #ifndef LOSS_MACHINE_H
22 #define LOSS_MACHINE_H
25 #include "sample_set.h"
31 LossMachine(int loss_type);
33 void get_loss_derivatives(SampleSet *samples,
35 scalar_t *derivatives);
37 scalar_t loss(SampleSet *samples, scalar_t *responses);
39 scalar_t optimal_weight(SampleSet *sample_set,
40 scalar_t *weak_learner_responses,
41 scalar_t *current_responses);
43 /* This method returns in sample_nb_occurences[k] the number of time
44 the example k was sampled, and in sample_responses[k] the
45 consistent response so that the overall loss remains the same. If
46 allow_duplicates is set to 1, all samples will have an identical
47 response (i.e. weight), but some may have more than one
48 occurence. On the contrary, if allow_duplicates is 0, samples
49 will all have only one occurence (or zero) but the responses may
50 vary to account for the multiple sampling. */
52 void subsample(int nb, scalar_t *labels, scalar_t *responses,
53 int nb_to_sample, int *sample_nb_occurences, scalar_t *sample_responses,
54 int allow_duplicates);