protected function getBestClassifier(): Classifier
    {
        $ref = new ReflectionClass($this->baseClassifier);
        /** @var Classifier $classifier */
        $classifier = count($this->classifierOptions) === 0 ? $ref->newInstance() : $ref->newInstanceArgs($this->classifierOptions);

        if ($classifier instanceof WeightedClassifier) {
            $classifier->setSampleWeights($this->weights);
            $classifier->train($this->samples, $this->targets);
        } else {
            [$samples, $targets] = $this->resample();
            $classifier->train($samples, $targets);
        }

        return $classifier;
    }
protected function getBestClassifier(): Classifier
    {
        $ref = new ReflectionClass($this->baseClassifier);
        /** @var Classifier $classifier */
        $classifier = count($this->classifierOptions) === 0 ? $ref->newInstance() : $ref->newInstanceArgs($this->classifierOptions);

        if ($classifier instanceof WeightedClassifier) {
            $classifier->setSampleWeights($this->weights);
            $classifier->train($this->samples, $this->targets);
        } else {
            [$samples, $targets] = $this->resample();
            $classifier->train($samples, $targets);
        }

        return $classifier;
    }
protected function getBestClassifier ( ) : Classifier { $ ref = new ReflectionClass ( $ this -> baseClassifier ) ; /** @var Classifier $classifier */ $ classifier = count ( $ this -> classifierOptions ) === 0 ? $ ref -> newInstance ( ) : $ ref -> newInstanceArgs ( $ this -> classifierOptions ) ; if ( $ classifier instanceof WeightedClassifier ) { $ classifier -> setSampleWeights ( $ this -> weights ) ; $ classifier -> train ( $ this -> samples , $ this -> targets ) ; } else { [ $ samples , $ targets ] = $ this -> resample ( ) ; $ classifier -> train ( $ samples , $ targets ) ; } return $ classifier ; }
Returns the classifier with the lowest error rate with the
consideration of current sample weights
Returns the classifier with the lowest error rate with the consideration of current sample weights