*/ public function compatibility() : array { return [ EstimatorType::classifier(), EstimatorType::anomalyDetector(), ]; } /** * Score a set of predictions. * * @param list $predictions * @param list $labels * @return float */ public function score(array $predictions, array $labels) : float { PredictionAndLabelCountsAreEqual::with($predictions, $labels)->check(); if (empty($predictions)) { return 0.0; } $score = 0.0; foreach ($predictions as $i => $prediction) { if ($prediction == $labels[$i]) { ++$score; } } return $score / count($predictions); } /** * Return the string representation of the object. * * @internal * * @return string */ public function __toString() : string { return 'Accuracy'; } }