Week 3 assignment: MSE equation

I am a little confused, I grabbed this equation from the lab. If you look at the image below, you notice that I included the MSE equation. When I look at this equation it seems, to me, that it is yhat-y. However, I know that the actual equation is y-yhat. Can someone explain to me what x_i and y_i is actually?


Hello @Nathan_Angell

Let’s just focus on this first:

Why do you think that is the actual equation? How do you know which one is actual?


I think that is the equation because I am thinking, y_i is the actual y. so that means x_i just means it is yhat.

simply by process of elimination

I agreed that f_{w,b}(x^{(i)}_{test}) is yhat.

But you are comparing between

  1. yhat - y
  2. y - yhat

You said equation 2 is the actual equation. Why do you think equation 2 is the actual equation, and equation 1 is not the actual equation?

Because I looked it up on google. I looked up ‘mse equation in python’ and it brought me to this website that showed 2 is the actual answer.

I see. Thank you.

Actually, both equations are correct. Both equations will lead to the same cost value, and both equations will lead to the same gradient formula.

You can substitute yhat = 3, and y = 2, and do the calculation in either way, the results will be the same. Just don’t forget the square.

Right when you said both values will lead to the same cost, I immediately understood. Just a simple example; if yhat is 3 and y is 1. if you do 1-3 squared that is 4. if you do 3-1 squared, that is also 4.

thank you so much for your input and help!