Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Predicting Prices Using Two Features | Section
Regression with Python

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

Your task is to build a Multiple Linear Regression model using the OLS class. Also, you will print the summary table to look at the p-values of each feature.

Tâche

Swipe to start coding

  1. Assign the 'age' and 'square_feet' columns of df to X.
  2. Preprocess the X for the OLS's class constructor.
  3. Build and train the model using the OLS class.
  4. Preprocess the X_new array the same as X.
  5. Predict the target for X_new.
  6. Print the model's summary table.

Solution

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

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 10
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

close

bookChallenge: Predicting Prices Using Two Features

Glissez pour afficher le 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

Your task is to build a Multiple Linear Regression model using the OLS class. Also, you will print the summary table to look at the p-values of each feature.

Tâche

Swipe to start coding

  1. Assign the 'age' and 'square_feet' columns of df to X.
  2. Preprocess the X for the OLS's class constructor.
  3. Build and train the model using the OLS class.
  4. Preprocess the X_new array the same as X.
  5. Predict the target for X_new.
  6. Print the model's summary table.

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 desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 10
single

single

some-alt