Sunday, 9 November 2025

Deep Learning 08 :Mean Square Error (MSE)

 

๐ŸŽฏ What It Is

Mean Squared Error (MSE) is a way to measure how wrong a model’s predictions are.
It tells you how far off your predictions are from the actual (true) values.


๐Ÿงฎ Formula:

MSE=1ni=1n(yiyi^)2\text{MSE} = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y_i})^2

Where:

  • yiy_i = actual (true) value

  • yi^\hat{y_i} = predicted value

  • nn = number of samples


⚙️ Step-by-Step:

  1. Find the error for each prediction: (yiyi^)(y_i - \hat{y_i})

  2. Square the error → makes all values positive and punishes big errors more

  3. Average them → gives the mean squared error


๐Ÿ“Š Example:

Actual (y)Predicted (ลท)ErrorSquared Error
45-11
23-11
6511
3211
MSE=1+1+1+14=1\text{MSE} = \frac{1+1+1+1}{4} = 1

๐Ÿ’ก Why It’s Used

  • It gives a single number that shows overall prediction quality.

  • Smaller MSE → better model

  • Commonly used in regression tasks and training neural networks (as a loss function).


๐Ÿ”ฅ Intuition:

MSE measures the average squared distance between your predictions and the truth.
The closer to 0, the better your model fits the data.


Would you like me to explain how MSE is used to train neural networks (via gradient descent)?

Eample : You’re trying to guess someone’s height ๐ŸŽฏ

If they say they’re 160 cm, and you guess 170 cm, you’re 10 cm off.

Now let’s see how Mean Squared Error (MSE) works — explained like you’re 10 ๐Ÿ‘‡


๐ŸŽ Step-by-Step:

  1. You make several guesses.
    Example:

    True heightYour guessError
    160170+10
    150145-5
    180190+10
  2. You take the difference (error) for each guess.

  3. You square each error (so negative numbers don’t cancel out):
    102=10010^2 = 100, (5)2=25 (-5)^2 = 25, 102=10010^2 = 100

  4. You average them all:

    (100+25+100)/3=75(100 + 25 + 100) / 3 = 75

That’s your Mean Squared Error = 75


๐Ÿง  What It Means:

  • If MSE = big number → your guesses are way off ❌

  • If MSE = small number → your guesses are close ✅


๐Ÿ’ฌ In short:

MSE tells you how wrong your guesses are —
it’s like checking how far your dart hits are from the bullseye ๐ŸŽฏ,
but you square the distance so big misses hurt extra!

No comments:

Post a Comment

Data Engineering - Client Interview question regarding data collection.

What is the source of data How the data will be extracted from the source What will the data format be? How often should data be collected? ...