Week 2 Practice Lab Linear Regression -

I’m working on Exercise 1 here: Week 2 Practice Lab: linear Regression

The assignment is due tonight and I cannot figure out what’s wrong with my implementation. I keep receiving an “AssertionError” but I can’t understand what’s wrong with my code (screenshot below). I’ve attached a screenshot in which I simply cut/pasted the code from the hint and I still receive the error.

Can anyone give me a little guidance as to what I might be doing wrong?

1 Like

This error means your compute_cost() function is not returning the correct result. There is an error in the code you added.

Do not worry about the deadlines, they are only reminders and will automatically re-schedule.

2 Likes

Thank you for your answer. I do see now that the result is coming up incorrect. Based on the hint I do understand what the code is meant to be doing, but I’m at a loss as to where to begin creating the correct code or what variables to create for the code. Is there a step I’m missing somewhere in the process?

To be clear I’m not asking for the answer, but I just don’t know where to start to create the code.

1 Like

I believe the notebook contains some sections titled “Hint”. They are below the cell that has those functions.

Try clicking on the Hint title, and read the explanations.

2 Likes

Again, thank you for your assistance. I’ve been over the hints and added code as best I could. I am now getting an “IndexError.” I have

  1. In the error code (screenshot below), is there an indication of where the mistake in my code would be? (I’m new to Python, to be clear)
  2. Might the issue be with my indentation for the “f_wb”, “cost” or “cost_sum”?

You have hard-coded the value 97 into the function.
That is a mistake. Your code must work for any size of dataset.
There is a variable in the function that you should use instead of a hard-coded value.

1 Like

TMosh, thank you. I was able to work it out once I stepped through the code based on the hints (my brain is now a pretzel of course). I appreciate your help in getting me there!

1 Like