Chapter 1: Jupyter Fundamentals
Activity 1: Building a Third-Order Polynomial Model
- Scroll to the empty cells at the bottom of
Subtopic C
in your Jupyter Notebook. - These will be found beneath the linear-model MSE calculation cell under the
Activity
heading.Note
You should fill these empty cells in with code as we complete the activity. You may need to insert new cells as these become filled up; please do so as needed.
- We will first pull out our dependent feature from and target variable from
df.
using the following:y = df['MEDV'].values x = df['LSTAT'].values.reshape(-1,1)
This is identical to what we did earlier for the linear model.
- Verify what
x
looks like by printing the first few samples withprint(x[:3])
:Figure 1.49: Printing first three values of x using print()
Notice how each element in the array is itself an array with length 1. This is what
reshape(-1,1)
does, and it is the form expected by scikit-learn. - Transform
x
into "polynomial...