Can anyone explain the working of the codes in our optional lab? It seems much more is going behind than the things visible in the Notebook as typing only the visible items in the notebook in my IDE is not giving the same output as it should. I am facing difficulties to understand how the graphs are being plotted. The code regarding the operations are clear but not the graphing.
Help would be appreciated!!
The graded and ungraded labs import some functions from other files like utils.py
. You can easily access them. Open the lab/assignment, click the Jupyter Notebook logo (top left), and you will see all the associated files/folders.
2 Likes
Yes I have got all those files. But I want to know what is actually happening in there. I am not really understanding the codes where the graphs are being plotted.
If you don’t understand the code, then you need to take a course of Python to get started.
2 Likes
I run the codes in opetional lab and I got this error
NameError Traceback (most recent call last)
in
1 # x_train is the input variable (size in 1000 square feet)
2 # y_train is the target (price in 1000s of dollars)
----> 3 x_train = np.array([1.0, 2.0])
4 y_train = np.array([300.0, 500.0])
5 print(f"x_train = {x_train}")
NameError: name ‘np’ is not defined
I got NameError: name ‘np’ is not defined in my python and vs code . I searched alot but I couldn’t find the solution . please help me
the problem is I can’t import numpy lib in my optional lab or in my visual studio code.
If you are using your local computer, then you need to install all the required libraries/framework (with the same version as used in the assignment).
But in Coursera, you don’t need to install anything. Just run the above cells.
Watch this video:
It explained how to install libraries in the vs code.
I was able to get the lab notebooks to work in Visual Studio code after installing the following dependencies:
pip install numpy
pip install ipympl
pip install matplotlib
I had to restart Visual Studio Code after installing the libraries, but all of the lab visualizations worked after that.