Simplified misc.h and misc.cc.
[svrt.git] / classifier.h
1 /*
2  *  svrt is the ``Synthetic Visual Reasoning Test'', an image
3  *  generator for evaluating classification performance of machine
4  *  learning systems, humans and primates.
5  *
6  *  Copyright (c) 2009 Idiap Research Institute, http://www.idiap.ch/
7  *  Written by Francois Fleuret <francois.fleuret@idiap.ch>
8  *
9  *  This file is part of svrt.
10  *
11  *  svrt is free software: you can redistribute it and/or modify it
12  *  under the terms of the GNU General Public License version 3 as
13  *  published by the Free Software Foundation.
14  *
15  *  svrt is distributed in the hope that it will be useful, but
16  *  WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  *  General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with selector.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 #ifndef CLASSIFIER_H
26 #define CLASSIFIER_H
27
28 #include "misc.h"
29 #include "vignette.h"
30
31 class Classifier {
32 public:
33
34   // We need a virtual destructor since there are virtual methods
35   virtual ~Classifier();
36
37   // This method returns an upper-caps string to identify the classifier
38   virtual const char *name() = 0;
39
40   // Train the classifier from a set of vignettes. The labels are in the
41   // vignettes.
42   virtual void train(int nb_vignettes, Vignette *vignettes, int *labels) = 0;
43
44   // Compute a scalar value which should be strictly positive on
45   // positive vignettes and strictly negative on negative ones.
46   virtual scalar_t classify(Vignette *vignette) = 0;
47
48   // Read or write the classifier from or to a stream
49   virtual void read(istream *in) = 0;
50   virtual void write(ostream *out) = 0;
51 };
52
53 #endif