C2 W2: Programming Assignment: Optimization Using Gradient Descent: Linear Regression - Execrise 3

I don’t understand why I am getting the output wrong for this exercise.
I am on week 2 of the course Calculus for Machine Learning and Data Science
](Coursera | Online Courses & Credentials From Top Educators. Join for Free | Coursera

{moderator edit: code removed}

You’re writing too much code.

All you need to do is call lr_sklearn.fit(…), and pass it the correct data.
It’s one line of code.
The data set was already created in the previous cell.

So, just delete all of this code:

I made the changes tho now I get the wrong output

Did you save and checkpoint before submitting?

It was autosaved.

Autosave does not always work.

Ah ok. Then I have to fix the output since I am not sure where the mistake might be if I needed only one piece of code

Did you perhaps modify the earlier cells that created the data set?

I mean what I remember was that I was writing the code and trying to find the right sequence of numbers to get the expected output. I didn’t see any of the earlier cells of the data set.

The data set is created in Cell 14 as I posted in an earlier screen capture.

The code that creates the X and Y data starts in Cell 3 where the data set is read from a file:

The X and Y are created from the adv dataset.

Then X_sklearn and Y_sklearn are created as we previously discussed.

You should not modify any of the code except for the places it says “START CODE HERE”.

I see. Is there anyway to reset this specific exercise or no?

Yes, there is:

From the File menu, use “Rename” to change the name of your current notebook.
From the Help menu, use “Get latest version”. this will put a copy of the notebook into your file folder, with the original file name.
In the File → Open menu, double-click on the notebook with the original name.

This will open a fresh copy of the notebook in your browser for editing.

Ok I was able to create a new file tho when I just include lr_sklearn.fit(X_sklearn,Y_sklearn).

Every time you open a notebook, you have to run all of the cells starting from the top. That’s where the assets are imported and the environment is created.

For example, lr_sklearn() is created when you run this cell:

Interesting cause I also run from the top but I always get errors that some term is not defined despite being declared in the previous cell.

That is very puzzling.

Please do this experiment.

Open your notebook.
Go to the “Kernel” menu and click “restart and clear output”.
Go to the Cell menu and click Run All.

Wait until all of the cells run, or you get a runtime error.

If you see any errors, post back a screen capture image of it.

I was able to resolve the issue.

I had modified the X and Y values in exercise 1 which was causing the issue.

So now I was able to finish the assignment.

That’s good news! Thanks for your report.

Your welcome