Home / Maths for AI / Symbols / Machine learning notation

Y hat (prediction)

Say it: "y hat"

What it means

A hat means "an estimate of": y^\hat{y} is the model's prediction of the true value yy; θ^\hat{\theta} is an estimated parameter.

Example

y^=2x+1,error=y−y^\hat{y} = 2x + 1, \quad \text{error} = y - \hat{y}

In code

import numpy as np
y = np.array([3.0, 5.0, 8.0])
y_hat = np.array([3.2, 4.9, 7.1])
print("errors:", (y - y_hat).round(2), "MSE:", round(np.mean((y - y_hat) ** 2), 3))

Output

errors: [-0.2  0.1  0.9] MSE: 0.287

Where it appears in machine learning

Losses compare y^\hat{y} with yy: MSE =1n∑(yi−y^i)2= \frac{1}{n}\sum (y_i - \hat{y}_i)^2.

Related symbols

Learn it properly in the free lesson Optimisation, with practice questions that check your answers.