*/ public function compatibility() : array { return [ EstimatorType::regressor(), ]; } /** * 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; } $error = 0.0; foreach ($predictions as $i => $prediction) { $label = $labels[$i]; $error += 100.0 * abs(($prediction - $label) / ((abs($label) + abs($prediction)) ?: EPSILON)); } return -($error / count($predictions)); } /** * Return the string representation of the object. * * @internal * * @return string */ public function __toString() : string { return 'SMAPE'; } }