Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Predicting Prices Using Two Features | Section
Supervised Learning Essentials

bookChallenge: Predicting Prices Using Two Features

For this challenge, the same housing dataset will be used. However, now it has two features: age and area of the house (columns 'age' and 'square_feet').

1234
import pandas as pd df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/b22d1166-efda-45e8-979e-6c3ecfc566fc/houseprices.csv') print(df.head())
copy
Task

Swipe to start coding

  1. Assign the 'age' and 'square_feet' columns of df to X.
  2. Initialize the LinearRegression model.
  3. Fit the model using X and y.
  4. Predict the target for X_new and store it in y_pred.
  5. Print the model's intercept and coefficients.

Solution

If you did everything right, you got the p-values close to zero. That means all our features are significant for the model.

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 9
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

bookChallenge: Predicting Prices Using Two Features

Swipe to show menu

For this challenge, the same housing dataset will be used. However, now it has two features: age and area of the house (columns 'age' and 'square_feet').

1234
import pandas as pd df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/b22d1166-efda-45e8-979e-6c3ecfc566fc/houseprices.csv') print(df.head())
copy
Task

Swipe to start coding

  1. Assign the 'age' and 'square_feet' columns of df to X.
  2. Initialize the LinearRegression model.
  3. Fit the model using X and y.
  4. Predict the target for X_new and store it in y_pred.
  5. Print the model's intercept and coefficients.

Solution

If you did everything right, you got the p-values close to zero. That means all our features are significant for the model.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 9
single

single

some-alt