Phpml\Metric\Accuracy::score PHP Method

score() public static method

public static score ( array $actualLabels, array $predictedLabels, boolean $normalize = true ) : float | integer
$actualLabels array
$predictedLabels array
$normalize boolean
return float | integer
    public static function score(array $actualLabels, array $predictedLabels, bool $normalize = true)
    {
        if (count($actualLabels) != count($predictedLabels)) {
            throw InvalidArgumentException::arraySizeNotMatch();
        }
        $score = 0;
        foreach ($actualLabels as $index => $label) {
            if ($label == $predictedLabels[$index]) {
                ++$score;
            }
        }
        if ($normalize) {
            $score = $score / count($actualLabels);
        }
        return $score;
    }
Accuracy