C1_W2_Linear_Regression - NameError: name 'load_data' is not defined

When creating a post, please add:

  • Week # must be added in the tags option of the post.
  • Link to the classroom item you are referring to:
  • Description (include relevant info but please do not post solution code or your entire notebook)

Hi, I am doing the W2 lab and I am stuck with this error after running the code below.

load the dataset

x_train, y_train = load_data()

NameError Traceback (most recent call last)
Cell In[12], line 2
1 # load the dataset
----> 2 x_train, y_train = load_data()

NameError: name ‘load_data’ is not defined

I have ran all the above cells and downloaded all the lab files.

Can you help point out what did I miss out please?

Thanks!

Hi @nancydane ,

Are you running the lab locally or in the browser environment? If you’re running it locally, make sure that the helper .py file containing load_data() is accessible to your code. If you’re in the browser lab, try restarting the kernel and running all cells again to make sure everything is properly loaded (or maybe reload the lab files).

Hope it helps! Feel free to ask if you need further assistance.

Every time you open a notebook file, you must run all of the cells starting from the top. That is where the assets are imported, and the workspace is created.

Hi Alireza, I am running using http://localhost:8888/notebooks and can’t get it working. Is the the preferred way?

Yes I run all cells from top…

The MLS course labs are intended to be run on the Coursera platform.

You have a pile of issues to address (primarily with version compatibility and installation) if you want to run them locally.

1 Like

Thanks, everyone! I just used the lab environment from Coursera instead of a local one. Codes now working!

3 Likes