A Data Project to Estimate House Sale Price

Posted on Apr 22, 2022

Blog Headline Photo by Kindel Media from Pexels

Data Science Background

For a home owner thinking of selling their home, a common dilemma is deciding whether to fix up aspects of their home in the hope of getting a better price or selling it as is. Many factors must be considered, including the extent of the fixes or renovations, available time, support network, and fundamentally, the cost [1]. To understand and quantify the added value of fixes or renovations, this project sought to analyze the Ames housing data set.

 

The Data Take-Aways

  • This project explored regression techniques for predicting house sale price using property features, such as house size, exterior condition, etc.
  • The predictive model revealed that the central air system, neighborhood, size, and kitchen quality result in the greatest impact on Sale Price.
  • To increase home value, home owners should consider the addition of a central air system, a kitchen update, and improvements to the house exterior.

Key Project Objective

The primary objective was to predict Sale Price for the Ames housing dataset using multiple variables or features describing each home and property.

A secondary goal was to identify renovation recommendations for Home Sellers.

Background Data

Ames is a city located in the state of Iowa. It’s a college town, and students make up half the population of this vibrant community with educational, cultural, recreational, and entertainment amenities.

Data Set

The Ames housing dataset was downloaded from kaggle.com.

Data Analysis

The data analysis procedure included (1) exploratory data analysis, (2) preprocessing, and (3) model training and comparison (Fig. 1).

data
Fig 1. Graphic of the data analysis procedure.

1. EDA: Data Wrangling & Visualizations

The housing dataset included 1460 rows and 81 columns.

Sale Price (USD) data ranged from $34.9K to $755K with a median sale price of $163K (Fig. 2A). Important to note, these houses were sold between the years of 2006-2010.

Initial visualizations revealed that Sale Price exhibited a right-skewed distribution (Fig. 2A). Because multiple linear regression models assume a normal distribution of the residuals, a log transformation was performed on Sale Price to ensure multiple linear regression results would be valid. This data transformation replaced the dependent variable of Sale Price (Fig. 2A) with log of Sale Price (Fig. 2B).

data
Fig 2. A: Distribution of Sale Price (USD). Sale Price data exhibited a right-skewed distribution. B: Distribution of the log of Sale Price. A log transformation was performed on Sale price to reduce the right-skewness of the data and ensure multiple linear regression results would be valid.

Following this, features were examined and visualized to understand each variable and build knowledge of the dataset. During this process, 15 homes were flagged as potentially erroneous due to discrepancies, often between two related features. The data cleaning process was outlined in more detail in the EDA_Data_Cleaning.ipynb notebook.

Missing data were also examined, and multiple features were imputed, including those related to the masonry veneer, lot frontage, basement, garage, fireplace, pool, alley, and fence data. Finally, three homes were removed due to their large Home Sizes (feet2) with z-scores greater than 4.5, which means that these samples were 4.5 standard deviations above the mean house size.

The subsequent sections examined house features related to Home Size, Curb Appeal, Kitchen, Heating + Central Air, Basement, and Location versus log of Sale Price. The primary purpose was to understand patterns within the dataset and the relationships between these features and log of Sale Price.

HOME SIZE

An important feature that is often used as an initial filter in a home search is its square footage. Square footage or house size refers to the area or living space. For a prospective buyer, this number quickly tells them if this home will meet their space needs, and it is typically used in a home value calculation (i.e. price per foot2).

For this dataset, the median square footage or house size was 1459 ft2 with three bedrooms and two bathrooms (Fig. 3). Pearson correlation coefficients were computed to assess the linear relationship between these features and the log of Sale Price. There were strong, positive correlations between House Size and Number of Bathrooms with the log of Sale Price (r = 0.721 and 0.648, Fig. 3).

data
Fig 3. A: Distributions of the dataset features related to home size. For each feature, the median was annotated. B. Scatter plots of the home size features and the log of Sale Price. For each linear relationship examined, a least squares regression line was depicted, and the correlation coefficient was annotated.

CURB APPEAL DATA

Curb appeal is the outward attractiveness of the home, the first impression a prospective buyer has as they walk up to the property. In this dataset, there were four exterior material ratings: Excellent, Good, Average, and Fair (Fig. 4A) and fifteen exterior materials types (Fig. 4B).

For Exterior Material Rating, a between groups ANOVA revealed a significant difference in log of Sale Price between at least two Exterior Material Ratings (F(3,1437)=411.7, p<0.05, Fig. 4A). Further, the effect size was calculated [2] and found to be η² = 0.46, indicating that 46% of the variance in log of Sale Price can be explained by the Exterior Material Rating.

Post hoc tests indicated statistically significant differences in log of Sale Price between all four ratings (p<0.05, Fig. 4A). For the Exterior Materials, a between groups ANOVA revealed a significant difference in log of Sale Price between at least two Exterior Materials (F(14,1426)=23.9, p<0.05, Fig. 4B) and the effect size was calculated to be η² = 0.19.

data
Fig 4. A: The relationship between Exterior Material Rating and log of Sale Price. There were four exterior material ratings, including Excellent, Good, Average, and Fair. B: The relationship between Exterior Material and log of Sale Price. There were fifteen exterior materials types in this dataset.

KITCHEN DATA

Kitchens are often described as the center or heart of a home and can be a memorable feature for a touring prospective buyer. For Kitchen Quality, a between groups ANOVA revealed a significant difference in log of Sale Price between at least two Kitchen Quality ratings (F(3,1437)=384.63, p<0.05, Fig. 5). The effect size was also calculated and found to be η² = 0.45, indicating that 45% of the variance in log of Sale Price can be explained by the Kitchen Quality. Post hoc tests indicated statistically significant differences in log of Sale Prices between all four ratings (p<0.05, Fig. 5).

data
Fig 5. The relationship between Kitchen Quality and log of Sale Price. There were four exterior material ratings, including Excellent, Good, Average, and Fair.

HEATING + CENTRAL AIR DATA

For most places, the condition and availability of the heating and central air systems are huge factors in the decision of buying a home. For Heating System Rating, a between groups ANOVA revealed a significant difference in log of Sale Price between at least two Heating System Rating (F(4,1436)=110.83, p<0.05, Fig. 6A).

The effect size was also calculated to be η² = 0.24, indicating that 24% of the variance in the log of Sale Price can be explained by the Heating System Rating. For the Central Air System, a between groups ANOVA revealed a significant difference in log of Sale Price for the Central Air System factor (F(1,1439)=207.34, p<0.05, Fig. 6B). The effect size was also calculated to be η² = 13.

data
Fig 6. A: The relationship between Heating System Rating and log of Sale Price. There were five Heating System Ratings, including Excellent, Good, Average, and Fair, and Poor. B: The relationship between Central Air System and log of Sale Price with  two options: Yes or No.

BASEMENT DATA

A basement is the floor or part of a home which is often below ground level. In this dataset, the Basement Finish Type was a categorical variable describing the basement's quality as a living quarters (Fig. 7A). For Basement Finish Type, a between groups ANOVA revealed a significant difference in log of Sale Price between at least two Basement Finish Types (F(6,1434)=70.04, p<0.05, Fig. 7A) and an effect size of η² = 0.23.

Moreover, a larger Basement Finished Area was linked to a greater log of Sale price as indicated by a positive correlation between Basement Finished Area (feet2) and log of Sale Price (r = 0.382, Fig. 7B). Homes with Basement Finished Area = 0 are homes with an Unfinished Basement Finish Type or No Basement (Fig. 7A-B).

data
Fig 7 A: The relationship between Basement Finish Type and log of Sale Price. There were seven Basement Finish Types that describe the basement's quality as a living quarters. B: A scatter plot of Basement Finished Area and log of Sale Price. For this linear dependence, the correlation coefficient was annotated.

LOCATION DATA

"Location, location, location". Considering when a home is priced, its features and amenities are compared to nearby homes, neighborhood can be a driving factor in the calculation of home value. This dataset included 25 neighborhoods (Fig. 8). For Neighborhood, the between groups ANOVA revealed a statistically significant difference in log of Sale Price and at least two Neighborhoods (F(24,1416)=78.06, p<0.05, Fig. 8). Further, the effect size was calculated to be η² = 0.57, indicating that 57% of the variance in log of Sale Price can be explained by the Neighborhood.

data
Fig 8. The relationship between Neighborhood and log of Sale Price. There were 25 neighborhoods. Considering subsequent model interpretation, the neighborhoods were binned. Each neighborhood was assigned a Neighborhood Group based on the log of Sale Price. Each Neighborhood box plot was color-coded based on its Neighborhood Group number which is also annotated on the right-hand-side.

However, considering subsequent model interpretation, this categorical variable was binned into four neighborhood groups based on 25th, 50th, 75th percentiles of log of Sale Price (Fig. 8). For the Neighborhood Group, the between groups ANOVA revealed a statistically significant difference in log of Sale Price and at least two Neighborhood Groups (F(3,1437)=501.37, p<0.05).

The effect size was also calculated to be η² = 0.51, indicating that 51% of the variance in log of Sale Price can be explained by the Neighborhood Group. Post hoc tests indicated statistically significant differences in log of Sale Prices between all four Neighborhood Groups 1-4 (p<0.05, Fig. 8).

2. Preprocessing Data

Next, data were prepared for model training and split into train (80%) and test (20%) datasets (as outlined in Fig. 1).

3. Train Models

A model was trained with both linear and nonlinear modeling algorithms (Table 1).

data
Table 1. Modeling algorithms used to train model.

The criteria used to compare and select the final model was the logarithmic RMSE for the test dataset. The logarithmic RMSE represented how much the model's predicted results deviated from the actual log of Sale Price. From this, the Elastic Net model was selected with a logarithmic RMSE = 0.1156 (Table 2).

data
Table 2. Model Comparison and Evaluation

The RMSE in dollars was also calculated and was on average $19K-20K. The Elastic Net model also had an r2 values of 0.91 (test) and 0.92 (train) indicating the model explained 91-92% of the variance in log of Sale Price (Table 2).

From the predictions graph (Fig. 9), the Elastic Net model performs reasonably. However, there are standout failure points at the lower end of Actual log of Sale Price where the model over-predicts the log of Sale Price (Fig. 9).

data
Fig 9. For the Elastic Net Model, the Actual log of Sale Price versus the Predicted log of Sale Price.

Model Data Interpretation (The Sanity Check)

Finally, for the Elastic Net model, the percent increase or decrease in Sale Price was calculated for each coefficient (Fig. 10) [3].

data
Fig 10. A subset of the Elastic Net Model features versus the Percent Change in Sale Price (%).

SOME HIGHLIGHTS

  • Houses with a Central Air System (=YES) yields a 9.6% increase in Sale Price compared to a house with no Central Air System.
  • A house with an Excellent Kitchen Quality yields a 3.8% increase in Sale Price compared to the reference, a house with a Fair Kitchen Quality.
  • Houses a with Brick Face as the Exterior Material yields a 3.2% increase in Sale Price compared to the reference, a house with Stucco.
  • A house with an Excellent Heating System Rating yields a 2.1% increase in Sale Price compared to the reference, a house with a Poor Heating System Rating.
  • Houses with an Unfinished Basement yields a 1.7% decrease in Sale Price compared to the reference, a house with an Average Rec Room as their Basement Finished Type.
  • For every 500 feet2 (the standard deviation of Home Size) increase in Home Size, the house Sale Price increases by 7%.

Recommendations To Sellers

This project sought to quantify the added home value of potential house fixes and renovation projects. Below the house updates or renovations that will add the most home value are outlined for home owner consideration:

  1. Add a Central Air system (+9.6%)
  2. Update your Kitchen (+3.8%)
  3. Modify your Exterior Material to be Brick Face (+3.2%) or Metal Siding (+1.9%), and avoid using Wood Siding (-1.41%).
  4. Update your Heating System (+2.1%)
  5. Finish your Basement to avoid losing overall value (-1.7%)

Future Work

Future work will examine model failure points and flag homes for additional review, expand EDA with the intention of improving the Feature Engineering aspect of the project, and gather more data, e.g. related to the housing market, the seller's motivation, kitchen size, central air system quality, home layout, etc.

Connect with Author

Project GitHubLinkedIn, and Twitter.

References

[1] Miller, J. (2020, July 30). Should Your First Home Be a Fixer-Upper? Bob Villa.

[2] Eddy, S. (2010, October 31). Effect size for Analysis of Variance (ANOVA). PsychoHawks: Making Psychology Simple For Everyone.

[3] Ford, C. (2018, August 17). Interpreting Log Transformations in Linear Model. University of Virginia Library Research Data Services + Sciences.

The skills I demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

About Author

Mandy McClintock

I'm an NYC Data Science Academy Alumni with a passion for working with data and people!
View all posts by Mandy McClintock >

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 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