NYC Data Science Academy| Blog
Bootcamps
Lifetime Job Support Available Financing Available
Bootcamps
Data Science with Machine Learning Flagship 🏆 Data Analytics Bootcamp Artificial Intelligence Bootcamp New Release 🎉
Free Lesson
Intro to Data Science New Release 🎉
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook Graduate Outcomes Must See 🔥
Alumni
Success Stories Testimonials Alumni Directory Alumni Exclusive Study Program
Courses
View Bundled Courses
Financing Available
Bootcamp Prep Popular 🔥 Data Science Mastery Data Science Launchpad with Python View AI Courses Generative AI for Everyone New 🎉 Generative AI for Finance New 🎉 Generative AI for Marketing New 🎉
Bundle Up
Learn More and Save More
Combination of data science courses.
View Data Science Courses
Beginner
Introductory Python
Intermediate
Data Science Python: Data Analysis and Visualization Popular 🔥 Data Science R: Data Analysis and Visualization
Advanced
Data Science Python: Machine Learning Popular 🔥 Data Science R: Machine Learning Designing and Implementing Production MLOps New 🎉 Natural Language Processing for Production (NLP) New 🎉
Find Inspiration
Get Course Recommendation Must Try 💎 An Ultimate Guide to Become a Data Scientist
For Companies
For Companies
Corporate Offerings Hiring Partners Candidate Portfolio Hire Our Graduates
Students Work
Students Work
All Posts Capstone Data Visualization Machine Learning Python Projects R Projects
Tutorials
About
About
About Us Accreditation Contact Us Join Us FAQ Webinars Subscription An Ultimate Guide to
Become a Data Scientist
    Login
NYC Data Science Acedemy
Bootcamps
Courses
Students Work
About
Bootcamps
Bootcamps
Data Science with Machine Learning Flagship
Data Analytics Bootcamp
Artificial Intelligence Bootcamp New Release 🎉
Free Lessons
Intro to Data Science New Release 🎉
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook
Graduate Outcomes Must See 🔥
Alumni
Success Stories
Testimonials
Alumni Directory
Alumni Exclusive Study Program
Courses
Bundles
financing available
View All Bundles
Bootcamp Prep
Data Science Mastery
Data Science Launchpad with Python NEW!
View AI Courses
Generative AI for Everyone
Generative AI for Finance
Generative AI for Marketing
View Data Science Courses
View All Professional Development Courses
Beginner
Introductory Python
Intermediate
Python: Data Analysis and Visualization
R: Data Analysis and Visualization
Advanced
Python: Machine Learning
R: Machine Learning
Designing and Implementing Production MLOps
Natural Language Processing for Production (NLP)
For Companies
Corporate Offerings
Hiring Partners
Candidate Portfolio
Hire Our Graduates
Students Work
All Posts
Capstone
Data Visualization
Machine Learning
Python Projects
R Projects
About
Accreditation
About Us
Contact Us
Join Us
FAQ
Webinars
Subscription
An Ultimate Guide to Become a Data Scientist
Tutorials
Data Analytics
  • Learn Pandas
  • Learn NumPy
  • Learn SciPy
  • Learn Matplotlib
Machine Learning
  • Boosting
  • Random Forest
  • Linear Regression
  • Decision Tree
  • PCA
Interview by Companies
  • JPMC
  • Google
  • Facebook
Artificial Intelligence
  • Learn Generative AI
  • Learn ChatGPT-3.5
  • Learn ChatGPT-4
  • Learn Google Bard
Coding
  • Learn Python
  • Learn SQL
  • Learn MySQL
  • Learn NoSQL
  • Learn PySpark
  • Learn PyTorch
Interview Questions
  • Python Hard
  • R Easy
  • R Hard
  • SQL Easy
  • SQL Hard
  • Python Easy
Data Science Blog > Machine Learning > Data Study on The Zillow Zestimate Kaggle Competition

Data Study on The Zillow Zestimate Kaggle Competition

Yu-Han Chen, Julia Goldstein, Mike Ghoul and Andre Toujas
Posted on Sep 15, 2017
The skills the author demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

1. INTRODUCTION

Zillow is an online real estate database with data on homes across the United States. Data shows one of Zillow’s most popular features is a proprietary property value prediction algorithm: the Zestimate.  As one might imagine, Zillow is constantly trying to improve its Zestimate.  To help advance its accuracy even further,  it launched a Kaggle competition with a $1.2 million prize.  (Feel free to check our codes at Github.)

 

Objective

The objective of the Kaggle competition is to predict the logerror between the predicted log error and the actual log error. The log error is defined as:

logerror=log(Zestimate)−log(SalePrice)

In plain English, the goal of the competition is to predict the difference between the Zestimate and the actual sales price of homes. This may help Zillow identify where their algorithm falls short.

 

Data

Kaggle provided real estate data from three counties in and around Los Angeles, CA.  Each observation had 56 features; no additional features from outside data sources were allowed in the analysis.  The data was split into two files: a training set with the actual logerror and feature information for 90,725 properties and a prediction set with only the feature information for 2,985,217 properties.  Submissions were scored based on the mean absolute error across all predictions.

 

Workflow

Since we had only two weeks to complete the project, we implemented a workflow with four major components: exploratory data analysis (EDA), handling missingness, feature engineering, and modeling.  As shown below, we repeated the process to improve our model until the project deadline.

Data Study on The Zillow Zestimate Kaggle Competition

As illustrated above, the process was iterated, tuned and recycled until the project deadline when final submissions were due.

 

2. EDA

We began by exploring the training and test data to gain more insight into the overall task. As we were predicting log error and training our models on a subset of data, we first wanted to ensure that the data was normally distributed. This is an important step for maintaining the consistent distribution and performance. If we randomly split our training data into a training and test set, the model can perform differently on our test data if we do not have the same type of distribution.

Data Study on The Zillow Zestimate Kaggle Competition

There is a Gaussian (normal) distribution to the log error; this means that the random sample we use to test our model will have the same distribution as our overall data, and we can guard against overfitting.

In order to begin to understand which of the 56 features were useful for our models, we looked at the absolute log error in relation to some categorical variables. For example, we can see that the absolute log error distribution is closer to 0 for higher quality buildings.

Data Study on The Zillow Zestimate Kaggle Competition

Visualizing Data Using Latitude and Longitude

We also visualized the data using latitude and longitude to identify any additional features that might help us predict the error more accurately.

In the visualization above, pockets of newer homes are highlighted. Looking at the log error (transformed for the purposes of this graph), we can see that Zillow does a better job of predicting the actual sale price for newer homes.

Training Data vs Prediction Data

One of the major pitfalls of building a predictive model is overfitting. A model that has been overfitted will perform well on training data but fail to accurately predict new observations. In order to address this, we compared the training data to the prediction data.

Data Study on The Zillow Zestimate Kaggle Competition

Overall, the distributions of the training and test data (full properties set) were similar. There were some slight differences which may have impacted the accuracy of our models.

Given the total number of features, we looked at the correlation of numerical features with both the absolute log error and each other to identify variables that might be particularly helpful in prediction.

Data Study on The Zillow Zestimate Kaggle Competition

While we did not find any numerical variables strongly correlated to the absolute log error, we did identify groups of correlated features.

We also used Principal Component Analysis (PCA), to find groups of related variables. The PCA biplot (shown above) groups correlated variables. The closer the features are to one another, the more positively correlated they are. Features across from each other are negatively correlated. As expected, PCA grouped the tax variables and variables indicating home size (e.g., bedroom count, bathroom count) together.  These analyses helped us understand the relationships between features in our data set.

 

3. DATA PREPARATION  

Both the training and test data had a large number of missing values that required or attention. In the training data alone, 17 variables had over 90% missingness.

 

Imputation Strategy

In the base case, we utilized three imputation techniques. First, we identified several binary variables and imputed with 0 and 1. Second, we imputed continuous numerical variables using the mean and discrete numerical variables using the mode. Next, for variables with a larger percentage of missingness, we imputed randomly, using a weighted distribution of observed values in an attempt to maintain the original distribution.

 

Feature Selection & Engineering

Following imputation, we dropped variables based on three principles: extreme missingness, duplication, and zero variance. Variables with over 90% missingness and no feasible way to determine the correct value were dropped. If variables captured the same information, such as FIPS (Federal Information Processing Standard code) and Zip Code, we only kept one. Finally, variables with the same value across all observations were dropped as they would have had no impact on our model.

We also created new variables based on our findings from PCA, including Total Room Count (bedrooms + bathrooms), Age of Home (2017 - year built), and Value Ratio (parcel tax ÷ property tax).

 

4. MODELING

Linear Regression

We began by fitting a multiple linear regression model to our data to better understand how our features related to each other and impacted log error. As with any line, the regression line is described by an equation that relates the predictor and response variables by assigning coefficients to the predictor variables.  The coefficient is the “influence” of the predictor on the response, holding all other predictor variables constant. The equation for the regression line is the predictive “model.”  In the equation below, the 𝜷 are the coefficients, the “xi” are the predictor variables and the “yi” is the prediction.

Fitting a linear model requires a number of assumptions: homoscedasticity of residuals, independence of errors, linearity, normally distributed residuals and independence of predictor variables. Our model violated most of these assumptions, but we proceeded for the sake of exploration. We tried some standard transformations (e.g., Box Cox) to address these violations, but they did not yield better results.

We used all 25 features to train the initial linear model, which yielded poor results (an Adjusted R2 value of 0.002422.  The Adjusted R2 value measures the effectiveness of the model with respect to variance in the residuals. Next, we reduced the model complexity using several different methods: removal of features with high (> 5) variance inflation factors (VIFs), a stepwise feature reduction using both AIC and BIC values, a Ridge analysis, and a Lasso analysis.  See Ridge analysis results in the figure below:

As anticipated, model effectiveness with regards to Adjusted R^2 did not improve by much, but it was interesting to see the significant predictors across the different methods.  

 

Tree-Based Modeling

The other models we used for this project fell into the regression tree-based category. Tree-based modeling is based on a structure in which the data is partitioned repeatedly at each “decision node” to minimize the residual sum of squares (RSS), or the distance of each point to the average of that group in the partition.

Tree-based algorithms implement a recursive binary splitting approach to “grow” the tree that is both “top-down” and “greedy.”  “Top-down” means that the data set is split into binary components successively starting with one, initial node.  “Greedy” means that splits at each node are based on the option with the best possible outcome at that node, not based upon a future segmentation that may lead to a better final result.  

One downfall of this approach is that it may lead to overfitting. In the extreme case, each observation would have its own partition (aka terminal node).  In this case, the RSS would equal 0, but the model would perform poorly if required to predict a new observation that is not in the data set.  

 

Bagging (Bootstrap Aggregation)

Bootstrap Aggregation (aka “Bagging”) is a method to mitigate against over-fitting by simulating a larger training data set to reduce overall variance. Bootstrapping takes a sample of observations with replacement from the training set to create a new data set with an equal number of observations. To estimate the testing error of a bagged model, the model predicts the response for “out of bag” observations that were not used to grow the tree.  The results are then averaged to calculate the out of bag error.

 

Random Forest

Random forest is an ensembling, tree-based modeling technique that uses bootstrapped training sets to build a “forest” of decision trees. Random forest helps decrease correlation and reduce model variance by randomly selecting a subset of predictors to analyze at each node of the decision tree.  Overfitting is unlikely due to the random, de-correlated nature of the tree building process.

 

Gradient Boosting Machines (GBM)

GBM builds trees sequentially using the residuals from the previous trees to build the next tree.  Given a decision tree model, we fit a new tree to the residuals of the current tree. The new decision tree (based on the residuals) is then added to the current decision tree, and the residuals are updated.  To combat overfitting, the tree depth (number of splits away from the initial node) is limited, and a learning rate (shrinkage rate) is introduced.

 

Cross-Validation and Hyperparameter Tuning

For all models, K-fold cross-validation was performed in order to prevent overfitting and search for the optimal hyperparameter settings over a tuning grid.  K-fold cross-validation involves splitting the data into K folds, setting one fold aside, training a model with the other folds and testing with the fold that was set aside. The results are then averaged together for a single estimation with reduced variance. Due to time and computing power limitations, we limited our analyses to 5 and 10-fold cross-validation.

We also partitioned 25% of our training data and held it out for testing before we trained a full model with all training data.  This helped us quickly assess model performance without predicting log error for 2,985,217 observations and submitting our prediction to Kaggle for feedback.  

 

Hyperparameter Tuning

Hyperparameters are the “higher-level” model properties that have an effect on the model training process (e.g., learning/shrinkage rate, tree depth).  Our team used a grid search to obtain optimal hyperparameter settings for all models considered. Conceptually, a grid search iterates a model through a hyperparameter grid to find the combination of hyperparameters that minimizes the loss function (or maximizes the objective function, i.e. ROC). We also used a random search for optimal hyperparameters, but the results were similar and  the random search took much longer than the standard grid search.  

With more time, we would have attempted a Bayesian Optimization hyperparameter strategy since research suggests that this technique yields better results while expending less computational power and taking less time. Bayesian Optimization retains information from previously sampled points when searching for the global minimum/maximum of the objective function.  

 

Initial Results

GBM yielded the best results from our initial round of modeling. See the table below for the hyperparameters selected and results for the 3 model types:

 

5. MODEL ITERATION

We treated the results from our first round of modeling as a baseline and returned to the beginning of our workflow to try to improve our models. We implemented several strategies independently to see how they would affect our results.

 

Additional Strategies

  • Trimming Features by Importance: In order to reduce model complexity, we aggregated the most important features from each of our best initial model runs and chose 11 features to test.  Reducing model complexity actually reduced the accuracy of our models.
  • Additional Feature Engineering: We created additional features based on the most important features in our initial models.  For example, we created a metric to represent the ratio of the home’s structure tax to its land tax.  Some of these features improved the accuracy of our predictions and were used in predicting our final submission for log error.  
  • Adding External Features: Although not formally allowed by the Kaggle competition rules, we wanted to see if adding external features would help predict logerror. We incorporated several variables from the Census Bureau's 2015 American Community Survey, including median income, population, and monthly housing costs.  Unfortunately, adding these features did not improve our results.
  • Re-Imputation: In our second attempt, we used a “simpler” imputation strategy. Features that were originally imputed with a random weighted sample were instead imputed with either the mean or mode. This method did improve our results.
  • Handling of Outliers: Several features in our data set had outliers (observations greater than 3 standard deviations from the mean). We suspected these outliers might be affecting our model performance and tried a few strategies to replace them, including replacing them with the median and complete removal.  All of these strategies decreased the predictive power of our models.

 

Ensemble Learning:

Ensemble learning is used in machine learning because the generalization ability (predictive power) of an ensemble is greater than a single “learner” (model). For the best results, correlation between learners should be minimized - where one model is deficient, another might excel.  Ensemble learning did not improve our results, likely due to high model correlation.

 

Final Results

Our Random Forest model produced the lowest logerror across all models we tried. Surprisingly, a grid search for the optimal mtry (the number of randomly selected features that are analyzed at each decision node) returned a value of 1. Since several of our features were correlated, selecting only one feature at each node might produce the least correlated trees. The final model run results are captured in the table below:

 

6. SUMMARY AND CONCLUSIONS

Given the amount of missing data and relatively large number of features in this project, imputation strategy and feature engineering were very important with respect to reducing prediction error. Using a simple imputation strategy was the most significant factor to improving our results.

With more time, we would continue to iterate on our workflow and introduce new strategies to improve our model results.  There were several modeling techniques that the team did not have a chance to explore due to time constraints, including Neural Networks and Support Vector Regression. Given the importance of choosing the right imputation method, we would attempt methods that require more time and computational power, such as KNN.

 

 

 

 

 

About Authors

Yu-Han Chen

Yu-Han is currently pursuing a Master’s degree in Management and Systems at New York University, and being a part-time data scientist and teaching assistant at NYC Data Science Academy. In her prior role as a market research consultant,...
View all posts by Yu-Han Chen >

Julia Goldstein

Julia has over five years of experience delivering business insight through data analysis and visualization. As an analytics and management consultant, she was responsible for managing projects, identifying solutions, and developing support among senior-level stakeholders. Moving forward, Julia...
View all posts by Julia Goldstein >

Mike Ghoul

Mike is a strategic analyst with 5 years of financial services experience coupled with data science skills and an insatiable drive to solve problems. While at Morgan Stanley, he built predictive compensation models forecasting future costs and presented...
View all posts by Mike Ghoul >

Andre Toujas

“Why?” The question “why” has always intrigued Andre. That simple question is what made Andre pursue his degree in mechanical engineering, and answering “why” is what drives him as a data scientist. Two of his four NYCDSA projects...
View all posts by Andre Toujas >

Related Articles

Data Analysis
Injury Analysis of Soccer Players with Python
Machine Learning
Ames House Prices Predictions
Python
US Honey Production Analysis With Python (1998-2012)
Machine Learning
The Ames Data Set: Sales Price Tackled With Diverse Models
Python
EDA and machine learning Ames housing price prediction project

Leave a Comment

Cancel reply

You must be logged in to post a comment.

Nguyen Minh September 23, 2019
Could you give me source code??

View Posts by Categories

All Posts 2399 posts
AI 7 posts
AI Agent 2 posts
AI-based hotel recommendation 1 posts
AIForGood 1 posts
Alumni 60 posts
Animated Maps 1 posts
APIs 41 posts
Artificial Intelligence 2 posts
Artificial Intelligence 2 posts
AWS 13 posts
Banking 1 posts
Big Data 50 posts
Branch Analysis 1 posts
Capstone 206 posts
Career Education 7 posts
CLIP 1 posts
Community 72 posts
Congestion Zone 1 posts
Content Recommendation 1 posts
Cosine SImilarity 1 posts
Data Analysis 5 posts
Data Engineering 1 posts
Data Engineering 3 posts
Data Science 7 posts
Data Science News and Sharing 73 posts
Data Visualization 324 posts
Events 5 posts
Featured 37 posts
Function calling 1 posts
FutureTech 1 posts
Generative AI 5 posts
Hadoop 13 posts
Image Classification 1 posts
Innovation 2 posts
Kmeans Cluster 1 posts
LLM 6 posts
Machine Learning 364 posts
Marketing 1 posts
Meetup 144 posts
MLOPs 1 posts
Model Deployment 1 posts
Nagamas69 1 posts
NLP 1 posts
OpenAI 5 posts
OpenNYC Data 1 posts
pySpark 1 posts
Python 16 posts
Python 458 posts
Python data analysis 4 posts
Python Shiny 2 posts
R 404 posts
R Data Analysis 1 posts
R Shiny 560 posts
R Visualization 445 posts
RAG 1 posts
RoBERTa 1 posts
semantic rearch 2 posts
Spark 17 posts
SQL 1 posts
Streamlit 2 posts
Student Works 1687 posts
Tableau 12 posts
TensorFlow 3 posts
Traffic 1 posts
User Preference Modeling 1 posts
Vector database 2 posts
Web Scraping 483 posts
wukong138 1 posts

Our Recent Popular Posts

AI 4 AI: ChatGPT Unifies My Blog Posts
by Vinod Chugani
Dec 18, 2022
Meet Your Machine Learning Mentors: Kyle Gallatin
by Vivian Zhang
Nov 4, 2020
NICU Admissions and CCHD: Predicting Based on Data Analysis
by Paul Lee, Aron Berke, Bee Kim, Bettina Meier and Ira Villar
Jan 7, 2020

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

NYC Data Science Academy

NYC Data Science Academy teaches data science, trains companies and their employees to better profit from data, excels at big data project consulting, and connects trained Data Scientists to our industry.

NYC Data Science Academy is licensed by New York State Education Department.

Get detailed curriculum information about our
amazing bootcamp!

Please enter a valid email address
Sign up completed. Thank you!

Offerings

  • HOME
  • DATA SCIENCE BOOTCAMP
  • ONLINE DATA SCIENCE BOOTCAMP
  • Professional Development Courses
  • CORPORATE OFFERINGS
  • HIRING PARTNERS
  • About

  • About Us
  • Alumni
  • Blog
  • FAQ
  • Contact Us
  • Refund Policy
  • Join Us
  • SOCIAL MEDIA

    © 2025 NYC Data Science Academy
    All rights reserved. | Site Map
    Privacy Policy | Terms of Service
    Bootcamp Application