Numbers not matching expected plus assertion error

Any assistance is greatly appreciated.

The most likely causes of incorrect results in this assignment are:

  • incorrect indentation around the for-loops (this is particularly common if you’re a new Python programmer)
  • not using enough sets of parenthesis to force Python to combine the terms in the correct order.
2 Likes

Note that all the code for this assignment can be found in the ungraded labs earlier in Week 3.

1 Like

Your values are about twice as big as the expected values. Did you perhaps forget to divide by 2 somewhere? It’s hard to pinpoint the error without seeing the code. If you send the code to me directly I can take a look.

Best,
Alex

@aachandler, I looked at the notebook earlier today.

1 Like

Summary:
If you’re using for-loops over the features ‘j’, be sure that your code uses [j] when updating the dj_dw vector.

1 Like

Ah yes you’re absolutely right. I couldn’t spot the error but this is exactly it. I ended up suggesting to implement a vectorized approach which is much less prone to such errors.

Thanks for letting me know!

1 Like