Sectie 1. Hoofdstuk 10
single
Challenge: Predicting Prices Using Two Features
Veeg om het menu te tonen
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').
1234import 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())
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.
Taak
Swipe to start coding
- Assign the
'age'and'square_feet'columns ofdftoX. - Preprocess the
Xfor theOLS's class constructor. - Build and train the model using the
OLSclass. - Preprocess the
X_newarray the same asX. - Predict the target for
X_new. - Print the model's summary table.
Oplossing
If you did everything right, you got the p-values close to zero. That means all our features are significant for the model.
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 1. Hoofdstuk 10
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.