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$.

 
<?php

require_once __DIR__ '/code.php';

echo 
'Error: ' error(yTrue10.0yPredicted7.0) . PHP_EOL;

echo 
'Squared Error: ' squaredError(yTrue4.0yPredicted6.0) . PHP_EOL;
Result: Memory: 0.001 Mb Time running: < 0.001 sec.
Error: -3
Squared Error: 4

Explanation: −3 ⇒ 7 − 10 = −3
Explanation: 4 ⇒ (6 − 4)² = 2² = 4