X-Boost  2.3.8
AbsDecisionStump.h
Go to the documentation of this file.
1 /* XBoost: Ada-Boost and Friends on Haar/ICF/HOG Features, Library and ToolBox
2  *
3  * Copyright (c) 2008-2014 Paolo Medici <medici@ce.unipr.it>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 
21 #ifndef _ABS_DECISIONSTUMP_H
22 #define _ABS_DECISIONSTUMP_H
23 
29 #include <iostream>
30 #include <vector>
31 #include <string>
32 #include "Types.h"
33 
37 template<class DataType>
40  DataType thn, thp;
41 public:
42 
43  typedef int ReturnType;
44 
47 
48 public:
49 
51  inline int evaluate_feature(DataType value) const
52  {
53  return (value < thn) ? -1 : (value > thp) ? 1 : 0;
54  }
55 
56  static std::string signature() {
57  return "absdecisionstump";
58  }
59 };
60 
61 template<class DataType>
62 inline std::istream & operator >> (std::istream & in, AbsDecisionStump<DataType> & s)
63  {
64  in >> s.thn >> s.thp;
65  return in;
66  }
67 
68 template<class DataType>
69 inline std::ostream & operator << (std::ostream & out, const AbsDecisionStump<DataType> & s)
70  {
71  out << s.thn << ' ' << s.thp;
72  return out;
73  }
74 
75 #endif
Types involved in boosting.
static const ClassifierType Type
AbsDecisionStump is a DiscreteClassifier.
Definition: AbsDecisionStump.h:46
ClassifierType
Definition: Types.h:31
int evaluate_feature(DataType value) const
convert the feature value to {-1,0,+1} using thresholds
Definition: AbsDecisionStump.h:51
A Weak Classifier based on a Feature Extractor policy.
Definition: AbsDecisionStump.h:38
a dicrete classifier returns {-1,+1}
Definition: Types.h:32
DataType thn
neg, pos threshold
Definition: AbsDecisionStump.h:40