House Price Prediction with Machine Learning (Kaggle)

Seth Jackson
Posted on Jul 6, 2020

Intro

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.

 

Imputation

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.

Removal

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

Mode

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

Other

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.

 

Regressions

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

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.

Conclusion

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

Related Articles

Leave a Comment

No comments found.

View Posts by Categories


Our Recent Popular Posts


View Posts by Tags

2019 airbnb Alex Baransky alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus API Application artist aws 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 Bundles California Cancer Research capstone Career Career Day citibike clustering Coding Course Demo Course Report D3.js data Data Analyst data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization Deep Learning Demo Day Discount dplyr employer networking feature engineering Finance Financial Data Science Flask gbm Get Hired ggplot2 googleVis Hadoop higgs boson Hiring hiring partner events Hiring Partners Industry Experts Instructor Blog Instructor Interview Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter lasso regression Lead Data Scienctist Lead Data Scientist leaflet linear regression Logistic Regression machine learning Maps matplotlib Medical Research Meet the team meetup Networking neural network Neural networks New Courses nlp NYC NYC Data Science nyc data science academy NYC Open Data NYCDSA NYCDSA Alumni Online Online Bootcamp Open Data painter pandas Part-time Portfolio Development prediction Prework Programming PwC python python machine learning python scrapy python web scraping python webscraping Python Workshop R 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 Selenium sentiment analysis Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau team TensorFlow Testimonial tf-idf Top Data Science Bootcamp twitter visualization web scraping Weekend Course What to expect word cloud word2vec XGBoost yelp