X-Boost  2.3.8
SimpleDecisionStump.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 _SIMPLE_DECISION_STUMP_H
22 #define _SIMPLE_DECISION_STUMP_H
23 
29 #include "Types.h"
30 
33 template<class DataType>
35 
37  DataType th;
38 public:
39  typedef int ReturnType;
40 
43 
44 public:
45 
46 
48  inline int evaluate_feature(DataType value) const
49  {
50  return (value > th) ? 1 : -1;
51  }
52 
53  static std::string signature() {
54  return "simplestump";
55  }
56 
57 
58 };
59 
60 template<class DataType>
61 inline std::istream & operator >> (std::istream & in, SimpleDecisionStump<DataType> & s)
62 {
63  in >> s.th;
64  return in;
65 }
66 
67 template<class DataType>
68 inline std::ostream & operator << (std::ostream & out, const SimpleDecisionStump<DataType> & s)
69 {
70  out << s.th;
71  return out;
72 }
73 
74 #endif
Definition: SimpleDecisionStump.h:34
Types involved in boosting.
ClassifierType
Definition: Types.h:31
int evaluate_feature(DataType value) const
convert the feature value to {-1,+1} using internal threshold
Definition: SimpleDecisionStump.h:48
static const ClassifierType Type
SimpleDecisionStump is a DiscreteClassifier.
Definition: SimpleDecisionStump.h:42
DataType th
threshold value
Definition: SimpleDecisionStump.h:37
a dicrete classifier returns {-1,+1}
Definition: Types.h:32