float StrongClassifier::evaluate(const std::vector<float> &features) const { //feature
  float decision = 0;
  for (int i=0; i<m_weakClassifiers.size(); i++) {
    WeakClassifier weak = m_weakClassifiers.at(i);

    int sign;
    if ( (weak.threshold() > features[weak.dimension()] && !weak.isFlipped()) ||
            (weak.threshold() < features[weak.dimension()] && weak.isFlipped()) )
        sign = 1;
    else
        sign = -1;
    decision += weak.weight() * sign;
  }
  return decision;
}
Exemple #2
0
/**************************************
 * Fucntion: is_classifier_correct
 * -------------------------------
 * returns true if weak classifier (wc) correctly identified the 
 * feature vector (fv), false otherwise.
 */
bool AdaBooster::is_classifier_correct(WeakClassifier &wc, FeatureVector &fv){
	
	// check if threshold is greater than (or equal to) feature
	bool guess = ( wc.threshold() >= fv.at(wc.dimension()) );

	// if classifier is flipped, negate guess
	guess = wc.isFlipped() ? !guess : guess;

	// find actual value of point
	bool real = ( fv.val() == POS );

	// return if guess and real agree
	return ( real == guess );

}
/**********************************************
 * Function: classifierGuess
 * -------------------------
 * Returns true if classifier decided a feature was POS, otherwise return false
 */
bool ImageTester::classifierGuess(WeakClassifier &wc, float value){
  return ( (wc.threshold() > value && !wc.isFlipped()) ||
      (wc.threshold() < value && wc.isFlipped()) );
}