> $probabilities * @param list $labels * @return float */ public function score(array $probabilities, array $labels) : float { ProbabilityAndLabelCountsAreEqual::with($probabilities, $labels)->check(); $n = count($probabilities); if ($n === 0) { return 0.0; } $error = 0.0; foreach ($probabilities as $i => $dist) { $label = $labels[$i]; foreach ($dist as $class => $probability) { $expected = $class == $label ? 1.0 : 0.0; $error += ($probability - $expected) ** 2; } } $error /= $n; return -$error; } /** * {@inheritDoc} */ public function __toString() : string { return 'Brier Score'; } }