*/ public function compatibility() : array { return [ EstimatorType::clusterer(), ]; } /** * Score a set of predictions. * * @param list $predictions * @param list $labels * @throws \Rubix\ML\Exceptions\InvalidArgumentException * @return float */ public function score(array $predictions, array $labels) : float { $table = (new ContingencyTable())->generate($predictions, $labels); $score = 0.0; foreach ($table as $dist) { $score += max($dist) / (array_sum($dist) ?: EPSILON); } return $score / count($table); } /** * Return the string representation of the object. * * @internal * * @return string */ public function __toString() : string { return 'Homogeneity'; } }