*/ public function compatibility() : array { return [ EstimatorType::clusterer(), ]; } /** * Generate the report. * * @param list $predictions * @param list $labels * @return Report */ public function generate(array $predictions, array $labels) : Report { PredictionAndLabelCountsAreEqual::with($predictions, $labels)->check(); $clusters = array_unique($predictions); $classes = array_unique($labels); $table = array_fill_keys($clusters, array_fill_keys($classes, 0)); foreach ($predictions as $i => $prediction) { ++$table[$prediction][$labels[$i]]; } return new Report($table); } }