House price prediction

IT 545 Python for Data Analytics · Walsh College · Winter 2025

House price prediction

Five property features, three regression models: this page refits her linear, ridge and lasso models on the Kaggle house sales data and lets you price a home yourself.

Pythonpandasscikit-learnLinear regressionRidge & Lassoseaborn
-home sales in the Kaggle training set
-median sale price
-test R² of linear regression on her exact 80/20 split
-typical error (MAE) on unseen homes

Live demo

Three regression models are refit in your browser on every change and scored on the held-out 20% of homes.

Test-set scores (- homes)

Price estimator

-

Results

Both charts follow the current split and alpha settings.

Predicted vs actual price, test homes

Effect of a one-standard-deviation increase

How it works

  1. Loaded the Kaggle House Prices data with pandas, checked missing values and filled numeric gaps with column means.
  2. Explored relationships with a correlation heatmap and picked five strong, easy-to-explain predictors: overall quality, above-ground living area, garage capacity, basement area and year built.
  3. Split the homes 80/20 into training and test sets with random_state=42.
  4. Trained scikit-learn Linear Regression, Ridge (alpha=1) and Lasso (alpha=0.1), and evaluated them with mean squared error and R².
  5. Plotted predicted against actual prices to check fit. The notebook's printed results were not saved, so this page re-runs the same pipeline on the Kaggle training data: linear regression by normal equations, ridge and lasso by coordinate descent on standardized features.

Data

First 10 rows of the embedded extract. OverallQual is rated 1 to 10; areas are in square feet; GarageCars is garage capacity in cars.