Machine Learning Week 1: Optional lab Cost Function

Hi,

I have a small doubt in the cost function calculation in the optional lab session for linear regression.

When I select w=100, b=100 for the data x=[1,2] and y=[300,500], the appropriate cost function would be cost = 1/m * (100 ** 2 + 200 ** 2) but in the graph it is shown as 1/m * (5000 + 20000) .

But, if I select to divide the cost by 2m instead of m then I get the same value for the cost function.

But the representation on the graph is not correct I think.

Please correct me if I am wrong.

Regards,
Sudhakar

Hello @sudhakar.explore

In the case of your example:
The equation for cost = 1/2m * (100^2 + 200^2) = 1/m* ((100^2 + 200^2)/2) = 1/m * (100^2/2 + 200^2/2) = 1/m * (5000 + 20000).

And this is the value that is shown in the graph, so the calculation is correct. In the equation of cost that you mentioned above you used 1/m instead of 1/2m.

Hope its clear now.

Hi @shanup

Thank you for the quick response.

It is clear now.

Regards,
Sudhakar