Data: House Price Prediction with Machine Learning

Posted on Jul 6, 2020
The skills I demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.


This Kaggle competition involves predicting the price of housing using a dataset with 79 features. The data has missing values and other issues that need to be dealt with in order to run regressions on it. My code for this project can be found here.



Regressions don't handle missing values well, so they need to be replaced with a value. Each column uses the Imputation strategy most suited to it.


The following columns were removed due to them having so many null values that imputation is not feasible:

  1. MiscFeature - 96% null
  2. MiscValue - 96% null
  3. PoolQC - 99% null
  4. PoolArea - 99% null

NA as Class

The following columns had their missing values filled with a specific value to indicate that the attribute itself was not present.

  1. Alley - NA => 'No Alley'
  2. MasVnrType - NA => 'None'
  3. MasVnrArea - NA=> 0


These columns had their missing values filled with the mode value for that column, because the mode value was far more common than other values.

  1. All Basement Columns
  2. Electrical
  3. GarageCars
  4. GarageArea


These columns had a unique imputation strategy.

  1. LotFrontage - Value was set to the average value for its neighborhood.
  2. GarageYrBlt - Value was set to the year the house was built.


Column Transformations

To make columns more relevant to the data, they were transformed and replaced by new columns.

  1. GarageScore = GarageQual * GarageArea
  2. TotalFullBath = BsmtFullBath + FullBath
  3. TotalHalfBath = BsmtHalfBath + HalfBath
  4. TotalSF = GrLivArea + TotalBsmtSF

In addition to the above, SalePrice was transformed into LogSalePrice due to it being more normally distributed as seen below.



The following regression types were used in this project:

  1. MultiLinear Regression
  2. Ridge
  3. Lasso
  4. Elastic Net
  5. Random Forest
  6. Gradient Boost Tree
  7. Support Vector Machine

Hyperparameters were tuned using GridSearchCV. Once all regressions were complete, the average of their predictions were used to predict LogSalePrice.

Based on these results, the tree models performed best on the data, and the linear models did the worst. The difference in score between them is about 10%.

Β The linear models were faster than the tree models, with SVM and ElasticNet being the slowest due to high hyperparamater tuning. These times do not reflect the models in general, they display their times with the specific hyperparameters that were found using GridSearchCV

Feature Selection

Multiple methods of Feature Selection were considered to determine which variables were most important.


VIF, also known as Variance Inflation Factor, gives a number to each feature that shows how much it has in common with other features. High VIF scores are a sign that a feature contains redundant data, and may need to be removed. VIF columns are the columns with a VIF score less than 10

Both Linear and Lasso models perform better with VIF, but the rest do better with the complete dataset. For this reason, the complete dataset was used to get the final results. While VIF regressions had lower scores, the time to perform regressions was significantly faster due to having less data to work with.

Post Regression Feature Selection

Lasso and Gradient Boost models can be used to determine which features were most important in the model. The top 10 features for each model are shown here:

There are a lot of differences between them, but both are consistent in that Overall Quality and Total Square Feet are extremely important in determining house prices.


The final prediction was generated by averaging the predicted sale price from each model. The RSME of the final submission was 0.17251. It is a good first start, but more can be done to improve the results.

Future Work

  1. Hyperparameter tuning was implemented by focusing on a tradoff between speed and accuracy. Additional tuning that focuses purely on performance by including larger ranges with more values within them could improve the results.
  2. Using model stacking or weighted averages could yield better results when combining the model predictions.
  3. More experimentation with different types of feature selection, as well as combining different feature selection types for each model, could improve performance. For example, using the VIF on the linear models, but all features on the tree models, would yield higher scores overall.





About Author

Seth Jackson

Seth Jackson is an expert in logic, economics, and philosophy with over 10 years of experience writing software. After getting a BA in Computer Science, he completed NYCDSA's Data Science program in order to obtain insights from data...
View all posts by Seth Jackson >

Related Articles

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI