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 > Student Works > Using Data to Predict House Prices in Ames, Iowa

Using Data to Predict House Prices in Ames, Iowa

Jordan Runge, Joe Lu, Yunmei Zhang and Xuyuan (Alice) Zhang
Posted on Mar 27, 2020

The skills the authors demonstrated here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

Data Science Introduction

Based on data over the past 50 years, a core pillar of achieving the “American Dream” is owning your own home. The importance of this life milestone is reflected by the sheer size of the real estate market:

  • $35 trillion market at the time time of writing
  • 25% of all households’ net worth is in the form of owner occupied real estate
  • 15% of the American GDP is due to real estate-related spending
  • 850,000 builders work in the residential construction industry

Buying a home is often the largest and most important purchase that most people will make during their lives. The process involves tradeoffs between what is desired, what is necessary, and what is affordable. Historically, determining the true value of a home has been something of a black box, as its market value is only revealed at the time of sale.

While real estate analysts have long used data to produce high-level, retroactive assessments about the housing market, the task of assigning values to individual homes before a sale has largely been left to appraisers, real estate agents, and sellers themselves. But times are changing. The confluence of big data and increased computing power are making the process of homebuying more transparent.

In this post, our goal as aspiring data scientists is to ease the stress of homebuyers making their purchases by shining through the cloud of price uncertainty with data science and machine learning techniques. We will provide a case study of how data science can add value to the home-buying process through highly practical and widely applicable machine learning models to accurately predict the sale price of homes in Ames, Iowa.

Data Overview

We used a data set made publicly available on Kaggle to build our prediction model. The dataset contains 1460 observations of homes sold in Ames, Iowa, between 2006-2010. For each home, there are 80 features, of which 33 are continuous, 14 are ordinal, and 33 are categorical.

Missingness

Around 6 percent of the data was missing, and of this missing data, most of it was ‘missing’ for a reason. Any variable related to a home’s basement or garage with a missing value meant that this home did not have a basement or a garage, so missing values for these features were imputed as 0. Other variables with missing values were imputed by finding the mode or mean value of the missing variable among other similar houses.

For example, 4 houses were missing values for zoning, so we imputed these values by finding the mode zoning value for other homes in the same neighborhood. Likewise, for the one home that did not have a value for the size of its masonry veneer, we found the mean veneer area of all homes that were built with the same veneer material.

Using Data to AnalyzeOutliers

Linear models are not robust to outliers, meaning one outlier could influence the true relationship between the house price and the predictor significantly. Therefore, we removed any observation that was 5 or more standard deviations away from the mean sales price relative to any particular variable. We created scatterplots to complement and confirm our decision to remove outliers from our model.

Feature Engineering

Using Data to Analyze Continuous Features: 

To begin, we looked at which continuous variables were the most correlated with our response (housing price) via a correlation heatmap:

We kept this in the back of our minds for the rest of the variable selection process, as a guide towards which variables might exhibit high multicollinearity and as a sanity check for which variables might be dropped by Lasso (more on this below).

We reduced the number of continuous variables to 19 by combining or features that expressed related or redundant information. For instance, there were 4 separate variables that reported the number of bathrooms in a home – full bath, half bath, basement full bath, and basement half bath.

We combined these 4 features into a single variable that expressed the total number of bathrooms. We followed a similar process to create custom variables for the total square footage of the basement and of the total outdoor living areas (porches). We also created a custom variable for the house’s ‘age’ that considers the year a house was built, remodeled, and sold

Lastly, in order to normalize our data, we took the log of each home’s sale price and used this variable in our machine learning models explained further down.

Using Data to Analyze Ordinal Features:  

Of the 14 ordinal features’ scales, 4 were numeric, but 10 were represented by strings (e.g. excellent, good, average, fair, and poor). For each of these 10 features, we converted their strings to numeric values so that these features could be used in our linear regression model.

Using Data to Analyze Categorical Features:  

The last group of variables that needed to be modified were the categorical features. After our initial exploratory data analysis, we dummified the most significant categorical values so that they, too, could be used in our model. Now that our data had been cleaned, we began building the model.

Using Data to Analyze Machine Learning Models

Our feature engineering resulted in a total of 99 variables to be used in our model. While we were intentional in selecting variables that both described distinct aspects of a house and appeared to have the most significant influence on a house’s price, we used two techniques – Variance Inflation Factor (VIF) and Lasso regression – to eliminate as much multicollinearity between features as possible. We want to do this because multicollinearity causes the estimates of our coefficients to become unstable and causes the model to generalize poorly on new, previously-unseen, data.

After computing our features’ VIF, we dropped two features that were highly correlated with other, more significant features, such as garage cars (highly correlated with garage area), and total number of rooms (highly correlated with size of living area).

Using Data to Analyze Lasso

We used Lasso both to eliminate features with high multicollinearity and to create a predictive model. Lasso is a kind of regularized linear regression that captures the linear relationship between target variables and predictors. Compared with multiple linear regression, Lasso produces slightly biased linear models with much less model variance to achieve a higher predictive accuracy. The root cause of the high model variance is multicollinearity among features, which could result in over-estimated coefficients when applying multiple linear regression. Lasso fixes this problem by penalizing the model using a hyperparameter lambda.

Lambda controls the amount of penalization applied to the model. As lambda increases, it aggressively penalizes variables in the model, driving the coefficients for less important features to zero. However, we also want the model to contain as much information as possible and that is why we need to find the optimal lambda so that we can keep a balance in between.

The figure above shows our features’ behavior in the Lasso model. The lines to the chart’s far left that quickly drop to zero represent features that are less important to a home’s price, and the lines further to the right of the chart are more significant. The list to the right of the chart shows the top-12 features that most significantly influence a homes price. After passing our variables through a basic Lasso model, we eliminated over 30 more variables that were highly correlated and did not have a strong influence on a house’s overall price.

Using the top 60 features from the Lasso feature selection, we tuned lambda through 80/20 cross validation. The chart below shows the error values associated with different lambda values.

The goal of choosing the optimal lambda is to find the one that gives the lowest error on the test dataset. From the graph above, we chose 0.000056 as the optimal lambda which is the lowest point on the blue curve. By applying the optimal lambda to the lasso model, we obtained an RMSE score of 0.133 on Kaggle.

Using Data to analyze Gradient Boost Method

Gradient Boosting Method (GBM) is a tree based machine learning model that can capture nonlinear relationships between the target variable and predictors. It follows a sequential procedure such that each tree uses information from previously grown trees, and the addition of each new tree improves upon the performance of the previous trees. In doing so, GBM converts many weak learners into strong learners and increases its predictive accuracy.

Compared to a linear model, a tree-based model requires much less data preprocessing. For example, GBM allows the transformation of categorical strings into numeric values through the process of label encoding, as opposed to a Lasso model which requires dummification and results in extra columns with sparse information. Additionally, tree-based models are not sensitive to the scaling of input features, so log transformations or normalization are not required for tree-based models.

After data preprocessing, the data we fed to the GBM model contained 82 columns including both continuous and ordinal features.

The figure above shows the top 35 features in the order of feature importance ranked by the GBM model. It suggests that the age of the house, sizes of the living area, basement and garage, as well as the overall quality of the house have the strongest impact on a house price. Some other features such as number of bathrooms, kitchen quality and neighborhood also influence a house value.

Among the features over which homeowners have partial or total control over, the ones ranked at the top are: age of the house, basement quality, and kitchen quality. This implies that home renovations such as finishing the basement or installing granite countertops in the kitchen, may produce the highest return on investment, when the homeowner is ready to sell the house.

With these 35 features, we tuned the hyperparameters and obtained an error score of 0.135 on Kaggle.

Using Data to analyze Bayesian Ridge

Bayesian Ridge is a machine learning model that doesn’t try to find the “best” value of model parameters, but rather, it tries to determine the posterior distribution of the model parameters, which is conditional on the training inputs and outputs. It is similar to Lasso regularization, in the sense that it also balances between removing redundant features vs keeping enough features to accurately predict housing prices. However, it has many more hyperparameters to tune. The implementation in Python has four hyperparameters to tune, which takes a longer time to train through cross validation.

The inputted data that we used contained 99 columns in total, which includes continuous, dummified, and ordinal features. After tuning our Bayesian Ridge model, we obtained a 0.1324 error score on Kaggle.

Using Data to Analyze Ensembled Model

In the 2004 book The Wisdom of Crowds, author James Surowiecki presents cases in economics and psychology where the collective estimates generated by crowds outperform those of any single individual. In this book, the opening example was: the crowd at a county fair accurately guessed the weight of an ox when their individual guesses were averaged (the average was closer to the ox's true butchered weight than the estimates of most crowd members).

Data science often applies a similar concept – combining many weaker learners generates a strong learner. We created an ensemble of three models. By using a weighting of 25% Lasso, 40% GBM, 35% Bayesian Ridge, we obtained a Kaggle score of 0.1241, which is superior to any of the individual performances of the models, and this RMSE ranks in the top 20% of Kaggle scores.

While an ensemble model trades increased accuracy for decreased interpretability, if the goal of the client is to simply obtain the most accurate price prediction for a house, an ensemble model is the best model to use.

Conclusion

Using a data science pipeline consisting of EDA, imputing missing values, removing outliers, feature engineering, transforming predictors, and ensembling linear and nonlinear machine learning algorithms, we managed to:

  • Score in the top 20% ranking of Kaggle competitors for this dataset, which delivers accurate price predictions to help homebuyers gauge how high they should bid
  • Understand which features are the most significant in determining the value of a home, which is useful for homeowners seeking to increase their home’s resale value through renovations

Given the amount of data available, the possibilities for our next project in applying data science to the real estate market are virtually endless. In future work, we could expand upon our existing foundation by:

  • Including data on non-traditional factors such as the number of cafes within a defined radius to augment models and make more accurate housing price predictions
  • Building recommender systems to suggest properties that match homebuyers’ purchasing needs and financial goals
  • Making forecasts that develop and refine indices to accurately predict property prices many years in the future

We are excited to work together with you on further data science projects, within the real estate domain, or to other areas of business, given that the techniques that we used here are universally applicable and mostly domain-agnostic. Our contact information is listed below – do feel free to get in touch.

 

Joe Lu - Linkedin / Github / Email

Jordan Runge - Linkedin / Github / Email

Yunmei (May) Zhang - Linkedin / Github / Email

Xuyuan (Alice) Zhang - Linkedin / Github / Email

 

About Authors

Jordan Runge

Jordan is a former educator and veteran of multiple, venture-backed startups. He is interested in data science, entrepreneurship, education, and public policy. He lives in NYC with his wife and dog. Connect with Jordan on LinkedIn, https://www.linkedin.com/in/jordanrunge/.
View all posts by Jordan Runge >

Joe Lu

I am a data scientist with 4 years of modeling experience, and 7+ years of financial industry experience. I have a passion for leveraging the power of data science to solve business challenges. At Fidelity, I have upgraded,...
View all posts by Joe Lu >

Yunmei Zhang

Yunmei (May) graduated from Cornell University with a master degree in chemical engineering. After graduation, she started a career as a process engineer in a manufacturing company, where she utilized the power of data in problem solving and...
View all posts by Yunmei Zhang >

Xuyuan (Alice) Zhang

Alice recently completed her Master in Business Analytics at Brandeis International Business School. She has an interest in applying data science in the e-commerce and tourism areas. She is passionate about revealing and telling the “story” behind certain...
View all posts by Xuyuan (Alice) Zhang >

Leave a Comment

No comments found.

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