Cost_function formula_Difference between 2*m & m?

Good night!

In the notebook, the formula in the housing price for the cost is showing:
cost = (1/m)*([value1]+[value2])

But in the videos before this lab, the formula was:
cost = (1 / (2 * m)) * cost_sum

Why the difference between 2*m and only m?

Thanks!

Edit: And where can I download/check lab_utils_uni.py?

He explains some videos later, but I still have the question about lab_utils_uni.

Hello @Jordhan,

Go to the lab that uses lab_utils_uni.py, then on the menu bar, click “File” > “Open”, and it will show a file browser interface where you can look for that file.

Cheers,
Raymond

1 Like

Hello Jordhan,

Regarding your query over the use of 2m and m, I would just say that it’s a convenient method to get the computation done for gradient descent. The derivative term of the square function gets cancel out with 1/2 term.

The 1/m averages the squared error over the no. of components to reduce its impact on the function.

Here’s a link that will add more insights.

1 Like

Thanks, Raymond! It worked here :smiley:

Thanks for the explanation, also did some more research around the derivative and could understand better the formula, helped a lot!