VOOZH about

URL: https://www.geeksforgeeks.org/machine-learning/ml-boston-housing-kaggle-challenge-with-linear-regression/

⇱ Linear Regression using Boston Housing Dataset - ML - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Linear Regression using Boston Housing Dataset - ML

Last Updated : 11 Jul, 2025

Boston Housing Data: This dataset was taken from the StatLib library and is maintained by Carnegie Mellon University. This dataset concerns the housing prices in the housing city of Boston. The dataset provided has 506 instances with 13 features.
The Description of the dataset is taken from the below reference as shown in the table follows: 

👁 Image

Let's make the Linear Regression Model, predicting housing prices by Inputting Libraries and datasets.  

The shape of input Boston data and getting feature_names. 

👁 Image

👁 Image

 Converting data from nd-array to data frame and adding feature names to the data 

👁 Image

  Adding the 'Price' column to the dataset 

👁 Image

👁 Image

 Description of Boston dataset 

👁 Image

Info of Boston Dataset 

👁 Image

Getting input and output data and further splitting data to training and testing dataset. 

👁 Image

Applying Linear Regression Model to the dataset and predicting the prices.  

Plotting Scatter graph to show the prediction results - 'y_true' value vs 'y_pred' value.

👁 Image

Results of Linear Regression i.e. Mean Squared Error and Mean Absolute Error. 

Mean Square Error : 33.448979997676496
Mean Absolute Error : 3.8429092204444966

👁 Image

As per the result, our model is only 66.55% accurate. So, the prepared model is not very good for predicting housing prices. One can improve the prediction results using many other possible machine learning algorithms and techniques. 

Here are a few further steps on how you can improve your model.

  1. Feature Selection
  2. Cross-Validation
  3. Hyperparameter Tuning
Comment