Added the non-disclosed problems.
[svrt.git] / classifier_reader.cc
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 #include "misc.h"
26 #include "classifier_reader.h"
27 #include "naive_bayesian_classifier.h"
28 #include "boosted_classifier.h"
29
30 Classifier *read_classifier(istream *in) {
31   Classifier *result = 0;
32
33   unsigned int t;
34   read_var(in, &t);
35
36   switch(t) {
37   case CT_NAIVE_BAYESIAN:
38     cout << "Reading a CT_NAIVE_BAYESIAN." << endl;
39     result = new NaiveBayesianClassifier();
40     result->read(in);
41     break;
42   case CT_BOOSTED:
43     cout << "Reading a CT_BOOSTED." << endl;
44     result = new BoostedClassifier();
45     result->read(in);
46     break;
47   default:
48     cerr << "Unknown classifier type for reading." << endl;
49     abort();
50   }
51
52   return result;
53 }