concept

MAE, MSE and baselines

MAE = mean(abs(error)); MSE = mean(error squared); RMSE = sqrt(MSE). MAE and RMSE use target units; MSE uses squared units. Evaluate on the same held-out data; reject empty or mismatched inputs. These are teaching helpers, not public library APIs.

Formal Syntax & Structure

artificial-intelligence syntaxartificial-intelligence
error_metrics(actual, predicted)

Working Example

Example Snippetartificial-intelligence
from math import sqrt
def error_metrics(actual, predicted):    if not actual or len(actual) != len(predicted):        raise ValueError('Matching nonempty data required')    errors = [y - p for y, p in zip(actual, predicted)]    mae = sum(abs(e) for e in errors) / len(errors)    mse = sum(e ** 2 for e in errors) / len(errors)    return mae, mse, sqrt(mse)
mae, mse, rmse = error_metrics([5, 8], [4, 10])print(f'{mae:.2f} {mse:.2f} {rmse:.2f}')print(error_metrics([4, 4], [4, 4]))