public function cost(array $coefficients, array $features, float $outcome) : float
{
$penalty = 0.0;
foreach ($coefficients as $i => $coefficient) {
if ($i || !$this->ignoreFirst) {
$penalty += pow(abs($coefficient), $this->level);
}
}
return $this->gradient->cost($coefficients, $features, $outcome) + $this->lambda * $penalty / $this->level;
}