protected function evaluateClassifier(Classifier $classifier)
    {
        $total = (float) array_sum($this->weights);
        $wrong = 0;
        foreach ($this->samples as $index => $sample) {
            $predicted = $classifier->predict($sample);
            if ($predicted != $this->targets[$index]) {
                $wrong += $this->weights[$index];
            }
        }

        return $wrong / $total;
    }
protected function evaluateClassifier(Classifier $classifier)
    {
        $total = (float) array_sum($this->weights);
        $wrong = 0;
        foreach ($this->samples as $index => $sample) {
            $predicted = $classifier->predict($sample);
            if ($predicted != $this->targets[$index]) {
                $wrong += $this->weights[$index];
            }
        }

        return $wrong / $total;
    }
protected function evaluateClassifier ( Classifier $ classifier ) { $ total = ( float ) array_sum ( $ this -> weights ) ; $ wrong = 0 ; foreach ( $ this -> samples as $ index => $ sample ) { $ predicted = $ classifier -> predict ( $ sample ) ; if ( $ predicted != $ this -> targets [ $ index ] ) { $ wrong += $ this -> weights [ $ index ] ; } } return $ wrong / $ total ; }
Evaluates the classifier and returns the classification error rate

@param Classifier $classifier

@return float
Evaluates the classifier and returns the classification error rate