Linear regression week 2 programming assignment

I keep getting the error x_train is not defined and I’m unsure of why because I did all of the imports properly (I think) . can anyone help walk me through this please.

Hi @Tayler-Frances_Chapm,

x_train is right at the beginning of the notebook. Every time you open your notebook, you should rerun the code to the point where you are last stop working on, because Python kernel is an interactive interpreter.

Hi yes I reran the code at the beginning and continue to get the same error. Is it possible that there is a problem with my installed packages? I have anaconda running and followed the directions provided in the course for python installation.

Hi @Tayler-Frances_Chapm ,

Anaconda installs a lot more packages than what is needed for this course, and I could not find any directions provided in this course for Python installation recommending the use of Anaconda.

If you have all the packages installed and working, then, provided that the python version is the same as that used in the Coursera’s platform, it should run fine.

The problem of x_train not defined is likely the load_data() function failed, hence the variable x_train has not been created. The function load_data() is in If you didn’t download all the files and data to your local machine, that wouldn’t work. There is a simple way to download all the files to your machine:

on top of your opened notebook, you will see a button Lab Files, click on the button, a fresh pane will be opened on the right of your display window, click download all files.