Cost function formula (why 2m in denominator)

I knew about MSE, RMSE and MAE as measures of error in prediction w.r.t. SLR. Not sure I understood the formula; how come we have 2m in the denominator…isn’t that the MSE is the cost function for SLR?

Hi @mridul1979 !
Could you post the formula here so it would be easier for us to understand your question?

The ‘2’ in the denominator of the linear regression cost equation is purely a convenience, so that when the gradients are computed (the partial derivative of cost) there will be a ‘2’ in the numerator to cancel-out the 2 in the denominator. This saves one math operation in the gradient descent computations.

2 Likes

Here is the formula from the video lecture.
image
If we remove 2 from the denominator, isn’t the cost function the same as MSE.

isn’t it also reducing the J by 50% for a set of parameters?

Yes, but that is not important. The goal is to find the weights and biases that minimize the cost. The absolute magnitude of the cost is not significant.

1 Like

Yes.

I also confused about that! not found the valid reason for that.

See my other replies on this thread.

The way I understood based on inputs from TMosh:
We have a certain value of the cost function for some arbitrary w,b. Now, here it is not important to look at how the cost is derived (which is what adds to the confusion). The goal is to find the optimal values of w, b for which this cost is the minimum (or the curve J converges).