1#ifndef FSTSEARCHBRANCHANDBOUNDPREDICTORAVERAGING_H
2#define FSTSEARCHBRANCHANDBOUNDPREDICTORAVERAGING_H
93template<
class RETURNTYPE,
typename DIMTYPE>
94class Branch_And_Bound_Predictor_Averaging :
public Branch_And_Bound_Predictor<RETURNTYPE,DIMTYPE> {
96 Branch_And_Bound_Predictor_Averaging():
_gamma(1.0),
_delta(1) {
notify(
"Branch_And_Bound_Predictor_Averaging constructor.");}
97 virtual ~Branch_And_Bound_Predictor_Averaging() {
notify(
"Branch_And_Bound_Predictor_Averaging destructor.");}
99 virtual void initialize(
const DIMTYPE features)
override;
100 virtual bool learn(
const DIMTYPE feature,
const RETURNTYPE value)
override;
101 virtual bool predict(
const DIMTYPE feature, RETURNTYPE &value)
const override;
107 virtual std::ostream&
print(std::ostream& os)
const override;
116template<
class RETURNTYPE,
typename DIMTYPE>
122 for(DIMTYPE i=0;i<features;i++) {
_value[i]=0.0;
_count[i]=0;}
125template<
class RETURNTYPE,
typename DIMTYPE>
129 assert(feature<
_value.size());
135template<
class RETURNTYPE,
typename DIMTYPE>
138 assert(feature<
_value.size());
146template<
class RETURNTYPE,
typename DIMTYPE>
149 os <<
"Branch_And_Bound_Predictor_Averaging(gamma="<<
_gamma<<
", delta="<<
_delta<<
")";
153 if(
predict(i,val)) os << std::endl <<
"feature "<<i<<
": predictor value="<<val<<
", count="<<
_count[i];
156 if(cnt>0) os << std::endl <<
"Total count: "<<cnt;
Interface for Implementations of Prediction Mechanism in Fast Branch & Bound and Branch & Bound with ...
void set_delta(const unsigned int delta=1)
sets the minimum sample count a feature must reach before predict() returns a value (asserted >=1); d...
Definition branch_and_bound_predictor_averaging.hpp:105
std::vector< RETURNTYPE > _value
sums up 'learned' values
Definition branch_and_bound_predictor_averaging.hpp:109
unsigned int _delta
minimum sample count before predict() returns a value; see set_delta()
Definition branch_and_bound_predictor_averaging.hpp:113
std::vector< unsigned long > _count
records the number of summed up values
Definition branch_and_bound_predictor_averaging.hpp:110
virtual std::ostream & print(std::ostream &os) const override
writes gamma/delta plus, for every feature with at least one learned sample, its current predicted va...
Definition branch_and_bound_predictor_averaging.hpp:147
virtual void initialize(const DIMTYPE features) override
(re)initializes the per-feature sum/count accumulators to zero for features features; call before use...
Definition branch_and_bound_predictor_averaging.hpp:117
void set_gamma(const RETURNTYPE gamma=1.0)
sets the scaling factor applied to the averaged value in predict() (asserted >=0.0); default 1....
Definition branch_and_bound_predictor_averaging.hpp:104
virtual bool learn(const DIMTYPE feature, const RETURNTYPE value) override
adds one observed value (non-negative, asserted) to feature 's running sum and increments its sample ...
Definition branch_and_bound_predictor_averaging.hpp:126
virtual bool predict(const DIMTYPE feature, RETURNTYPE &value) const override
sets value to the gamma-scaled running average learned for feature and returns true,...
Definition branch_and_bound_predictor_averaging.hpp:136
RETURNTYPE _gamma
scaling factor applied to the averaged prediction; see set_gamma()
Definition branch_and_bound_predictor_averaging.hpp:112
unsigned long get_count(const DIMTYPE feature) const
the number of learn() calls recorded so far for feature - a diagnostic accessor, telling how well fou...
Definition branch_and_bound_predictor_averaging.hpp:102
FST4 specific error passing class.
The Feature Selection Toolbox 4 library: every library component – data access, criteria and classifi...
Definition data_accessor.hpp:80
void notify(const std::string msg)
Prints msg followed by a newline via syncout::print(); a no-op unless the preprocessor macro DEBUG is...
Definition global.hpp:112