A Data Project to Estimate House Sale Price
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 . 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.
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.
The Ames housing dataset was downloaded from kaggle.com.
The data analysis procedure included (1) exploratory data analysis, (2) preprocessing, and (3) model training and comparison (Fig. 1).
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).
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.
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).
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  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.
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).
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.
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).
"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.
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).
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).
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).
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) .
- 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:
- Add a Central Air system (+9.6%)
- Update your Kitchen (+3.8%)
- Modify your Exterior Material to be Brick Face (+3.2%) or Metal Siding (+1.9%), and avoid using Wood Siding (-1.41%).
- Update your Heating System (+2.1%)
- Finish your Basement to avoid losing overall value (-1.7%)
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
 Miller, J. (2020, July 30). Should Your First Home Be a Fixer-Upper? Bob Villa.
 Eddy, S. (2010, October 31). Effect size for Analysis of Variance (ANOVA). PsychoHawks: Making Psychology Simple For Everyone.
 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.