Course 1 Week 2 programming assignment, cost function question

I wrote my answer like below but can’t figure out why it is not correct. Can someone help please? thanks a lot

y_hat=x*m+b
total_cost=np.sum((y_hat-y)**2)/(2*m)

The error was

<class 'numpy.float64'>
Cost at initial w: 377446.185
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-95-335d76763737> in <module>
      9 # Public tests
     10 from public_tests import *
---> 11 compute_cost_test(compute_cost)

~/work/public_tests.py in compute_cost_test(target)
      9     initial_b = 3.0
     10     cost = target(x, y, initial_w, initial_b)
---> 11     assert cost == 0, f"Case 1: Cost must be 0 for a perfect prediction but got {cost}"
     12 
     13     # Case 2

AssertionError: Case 1: Cost must be 0 for a perfect prediction but got 60.0

y_hat = w*x+b

not x*m + b

1 Like

The weights are w.
The number of examples is m.

1 Like

Hi, @xy_ds Just replace the “m” with “w” and you should probably get the desired result.

Lab is not working

Hi,

It has been more than a week that my lab is not working. I have to finish the assignments for which lab practice must be done. How can I fix It?

Kindly help me.

Regards