21 #ifndef _WEIGHTED_PATTERN_RESPONSE_H
22 #define _WEIGHTED_PATTERN_RESPONSE_H
32 #include "Classifier/RealDecisionStump.h"
37 template<
class ResponseType>
57 bool operator < (const BinaryWeightedPatternResponse<ResponseType> & c)
const
59 return value < c.value;
72 for(
unsigned int i=0;i<n;++i)
74 double d = set.templates[i].category * set.templates[i].d;
76 for(
unsigned int j=0;j<n_feature;j++)
77 store[i + j * n].d = d;
84 template<
class FeatureExtractor,
class Set>
87 int stride = set.Size();
89 for(
int i=i0; i<i1; i++)
91 double d = set.templates[i].category * set.templates[i].d;
93 for(
int j=0; j<n_feature; ++j)
96 store[i+j*stride].
value = h[j].response( getData1(set.templates[i], set), getData2(set.templates[i], set) );
97 store[i+j*stride].
d = d;
104 template<
class FeatureExtractor,
class Set>
107 for(
unsigned int i =0; i<set.Size(); i++)
110 store[i].
value = h.response( getData1(set.templates[i], set), getData2(set.templates[i], set) );
114 store[i].
d = set.templates[i].category * set.templates[i].d;
128 template<
class FeatureExtractor,
class Set>
131 int min_resp, max_resp;
133 const int n_element = set.Size();
135 for(
int i =0; i < n_element; i++)
137 value[i] = h.response( getData1(set.templates[i], set), getData2(set.templates[i], set) );
138 if(i==0) { min_resp = max_resp = value[0]; }
140 if(min_resp > value[i]) min_resp = value[i];
141 if(max_resp < value[i]) max_resp = value[i];
146 bin_size = (max_resp - min_resp + 1 + n_bucket - 1) / n_bucket;
153 for(
int i = 0;i<n_bucket; ++i)
155 store[i].
value = min_resp + bin_size * i;
160 for(
int i =0; i< n_element; i++)
162 int bin = (value[i] - min_resp) / bin_size;
167 store[bin].
d += set.templates[i].category * set.templates[i].d;
172 template<
class ResponseType>
193 bool operator < (const WeightedPatternResponse<ResponseType> & c)
const
195 return value < c.value;
203 template<
class FeatureExtractor,
class Set>
206 long stride = set.Size();
208 for(
unsigned int i=i0; i<i1; i++)
211 for(
unsigned int j=0; j<n_feature; ++j)
214 store[i+j*stride].
value = h[j].response( getData1( set.templates[i], set), getData2( set.templates[i], set) );
216 store[i+j*stride].
d = set.templates[i].d;
217 store[i+j*stride].
category = set.templates[i].category;
224 template<
class FeatureExtractor,
class Set>
227 for(
unsigned int i =0; i<set.Size(); i++)
230 store[i].
value = h.response( getData1( set.templates[i], set), getData2( set.templates[i], set) );
234 store[i].
d = set.templates[i].d;
235 store[i].
category = set.templates[i].category;
ResponseType value
feature response associated with this pattern
Definition: WeightedPatternResponse.h:182
Definition: WeightedPatternResponse.h:173
A Weak Classifier based on a Feature Extractor policy.
Definition: DecisionStump.h:45
void ComputeFeaturesResponse(BinaryWeightedPatternResponse< int > *store, const FeatureExtractor *h, int n_feature, const Set &set, int i0, int i1)
Definition: WeightedPatternResponse.h:85
void ExtractFeature(BinaryWeightedPatternResponse< int > *store, const FeatureExtractor &h, const Set &set)
extract from templates feature using h and put in store, and associating the weighted category d ...
Definition: WeightedPatternResponse.h:105
void ExtractFeatureAndBucket(BinaryWeightedPatternResponse< int > *store, const FeatureExtractor &h, const Set &set, int n_bucket, int *value)
Definition: WeightedPatternResponse.h:129
void ExtractFeatureSubPart(WeightedPatternResponse< int > *store, const FeatureExtractor *h, int n_feature, const Set &set, int i0, int i1)
Definition: WeightedPatternResponse.h:204
ResponseType value
feature response associated with this pattern
Definition: WeightedPatternResponse.h:43
BinaryWeightedPatternResponse< int > PatternResponse
A weighted pattern response with integer values.
Definition: WeightedPatternResponse.h:64
void __InitializePatternResponse(BinaryWeightedPatternResponse< int > *store, int n_feature, const Set &set)
set up d field in BinaryWeightedPatternResponse
Definition: WeightedPatternResponse.h:68
A Weak Classifier based on a Feature Extractor policy.
Definition: RealDecisionStump.h:42
double d
Weight associated to this pattern.
Definition: WeightedPatternResponse.h:179
void sort_pattern(PatternResponse *store, int n)
Definition: MultiClassDecisionStump.h:72
a FeatureExtractor return a scalar number without relationship with classification ...
Definition: Types.h:35
Definition: WeightedPatternResponse.h:283
float GetWeightedCategory() const
return weighted category
Definition: WeightedPatternResponse.h:54
AdaBoost W+ metric (or any metric based on weighted pattern sum) for DecisionStumpPolicy (in this cas...
Definition: WeightedPatternResponse.h:242
double getWeight() const
return the weight associated to this class
Definition: WeightedPatternResponse.h:190
A simple decision stump for multiclass problem using only one threshold for all problems.
Definition: MultiClassDecisionStump.h:35
double d
Weight associated to this pattern with sign ( >0 = pos +1, <0 = neg -1)
Definition: WeightedPatternResponse.h:40
Definition: WeightedPatternResponse.h:291
double getWeight() const
return the weight associated to this class
Definition: WeightedPatternResponse.h:51
Definition: WeightedPatternResponse.h:38
A (really) weak classifier. Implements the policy DecisionStump for BinaryClassifier.
int getClass() const
return current class identifier (see above)
Definition: WeightedPatternResponse.h:48
int getClass() const
return current class identifier (see above)
Definition: WeightedPatternResponse.h:187
A (really) weak classifier for Multi-Class Problem Implements some MultiClassDecisionStump.
static double optimize(DecisionStump< int > &h, const PatternResponse *store, int n, double sum_d) __attribute__((deprecated))
void GenerateBucket(BinaryWeightedPatternResponse< int > *store, int n_bucket, const BinaryWeightedPatternResponse< int > *source, int n_element)
int category
category
Definition: WeightedPatternResponse.h:176