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