Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Applied Data Science with Python and Jupyter

You're reading from   Applied Data Science with Python and Jupyter Use powerful industry-standard tools to unlock new, actionable insights from your data

Arrow left icon
Product type Paperback
Published in Oct 2018
Publisher
ISBN-13 9781789958171
Length 192 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Alex Galea Alex Galea
Author Profile Icon Alex Galea
Alex Galea
Arrow right icon
View More author details
Toc

Chapter 1: Jupyter Fundamentals

Activity 1: Building a Third-Order Polynomial Model

  1. Scroll to the empty cells at the bottom of Subtopic C in your Jupyter Notebook.
  2. 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.

  3. 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.

  4. Verify what x looks like by printing the first few samples with print(x[:3]):
    Figure 1.49: Printing first three values of x using print()
    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.

  5. Transform x into "polynomial...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image