What is a model in the mathematical sense

Error as a measure of quality

Error is a function (commonly called a loss function) that compares the model’s prediction with the true value and returns a number that shows how wrong we were. The smaller this number, the better the model. For example, the simplest error is the difference between prediction and reality: $ŷ - y$.

In practice, we often use the squared error (Squared Error or SE), because it is always non‑negative and penalizes large mistakes more strongly: $(ŷ - y)^2$.

Example of use:

 
<?php

// Simple error: difference between prediction and true value
// ŷ - y. Positive means we overestimated, negative means we underestimated.
function error(float $yTruefloat $yPredicted): float {
    return 
$yPredicted $yTrue;
}

// Squared error: (ŷ - y)^2
// Always non‑negative and penalizes large mistakes more strongly than small ones.
function squaredError(float $yTruefloat $yPredicted): float {
    return (
$yPredicted $yTrue) ** 2;
}