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 Predicts Housing Prices in Ames, Iowa

Data Predicts Housing Prices in Ames, Iowa

Hugh Goode, David Jhang, Jung Lim and Jack Copeland
Posted on Dec 7, 2021
The skills we demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

Introduction

Data confirms the real estate market is constantly changing with moving economic factors (supply, demand, cost of living index, unemployment rates, etc.). Real estate buyers and sellers must constantly adjust pricing of products to be competitive in the marketplace. In order to be better informed when making pricing decisions, understanding trends and being able to make predictions about the future is imperative.

Overview of Data

The primary dataset for this project was taken from Kaggle and contained 2,580 observations of house sales for Ames, Iowa. The dataset contained 80 features (approximately 37 numeric type features and 43 categorical string type features). Recorded sale price was the target variable. The observations of sales provided were from January 2006 to March 2010. A supplemental Ames Real Estate dataset with information up to 2020 was used to incorporate addresses and geo-coordinates for each observation.

EDA

We conducted an exploratory data analysis to view the characteristics of this dataset. First, we plotted a histogram to view the distribution of the sale price.

The figure above shows the distribution is skewed right due to a small number of higher priced houses. When the houses with sale prices greater than $300,000 are filtered out the distribution appears to be normal.

Next, we made a correlation heat map of some of the numeric type features.

The lighter boxes represent higher correlation between the corresponding 2 features, and the darker boxes represent lower correlation between the corresponding 2 features.

PoolArea appears to have the least correlation with SalePrice. SalePrice was more correlated with GrLivArea, TotalBsmtSF, 1stFlrSF, and GarageArea. We also noticed that GrLivArea was somewhat correlated with 2ndFlrSF and 1stFlrSF which will be useful for the feature engineering.

Next, we took a look at the average sale price over time.

We can see from the chart above that the prices were generally increasing until the market crashed in 2009 and the average sale price plummeted. We also took a look at how the seasons affect transactions.

Data Predicts Housing Prices in Ames, Iowa

Data Predicts Housing Prices in Ames, Iowa

The graph above shows that the average sale price oscillates seasonally, hitting its peak in the summer and reaching its trough in the winter. Similarly, the second graph above shows the number of homes sold by season. The number of sales spikes in the summer and reaches its lows in the winter.

Finally, we took a look at the distribution of some of the numeric features.

Data Predicts Housing Prices in Ames, Iowa

We see that a large quantity of features have a significant number of 0 values, which means that a lot of houses are lacking that specific feature. The observation that the numeric features are not normally distributed was important as we scaled features for training the models.

Data Cleaning 

In order to ensure the models provide accurate and interpretable results, several steps were taken to clean the data and engineer new features.

First, we filtered out all sales that were not listed as a โ€œnormalโ€ sale condition. We did this as we realized that 94% of the recorded sales were normal and the ones that were not tended to be outliers and inconsistent in terms of sale price. All non-normal sales were removed from the dataset. Next, we created methods to handle null and missing values.

Every column in the dataset contained at least one missing value, and several had over 2,000 rows of null values. For each column, the team discussed whether it would be best to remove the feature or fill the null value with the mean of the column, zero, or some other value.

For numerical columns such as BsmtFinSF, MasVnrArea, BsmtFullBath, BsmtHalfBath, GarageCars, and GarageArea, we replaced null values with 0 as a null value represented the fact that the house did not contain the feature.

While for LotFrontage and GarageYrBlt, we decided to fill null values with the column mean as it often reflected poor quality in the data, not a missing feature. Lastly, for all categorical variables, we decided to fill all null values with a string that read โ€œno_variableโ€. This allowed us to easily use these tags for dummifiying and ordinal encoding in later stages of the project.

Feature Engineering

In addition to data cleaning, we also performed feature engineering in order to create helpful inputs and reduce multicollinearity.

The first step of this process was to find correlated variables and determine if any of them could be combined. We decided to make four features: total bath, total living area (square feet), basement unfinished ratio, and total rooms above ground (excluding bedrooms). After creating these features, we removed the features used to create them in order to avoid multicollinearity.

Lastly, we looked at ways to simplify our model and remove unnecessary features. Using a correlation plot and a preliminary lasso model as reference, we decided to remove 24 features. Often, these features were categorical and only a small percentage of the homes contained them. For example, only 10 houses in the dataset had a pool, so we decided to remove this feature all together.

We removed the following features from the dataset: GrLivArea, 1stFlrSF, 2ndFlrSF, BsmtFinSF1, BsmtFinSF2, BsmtUnfSF, FullBath, HalfBath, Street, Alley, Utilities, Condition2, RoofMatl, Heating, Electrical, LowQaulFinSF, Kitchen, GarageCars, GarageCond, PoolArea, PoolQC, MiscFeature, MiscValue.

Data Testing

After the feature engineering was completed, we did a cookโ€™s distance test to determine outlier observations within the data. Four observations with p-values < 0.05 were deemed outliers and removed from the data set.

We then created four different subsegments of the data after the testing was completed.

We created a training sample and testing sample for our linear models and a separate training sample and testing sample for our tree models. The linear models utilized one hot encoding for categorical variables while the tree models utilized label encoding. Both models used a MinMaxScaler for all numerical values that were trained on the training data exclusively. After these datasets were created, we were prepared for modeling.

Modeling

For the modeling portion of the project, 2 transformations of the data set were used. A dummified data set was used for the linear models (lasso, ridge, elastic, support vector regression) and a label encoded data set was used for the tree based models (random forest, gradient boost, cat boost). The transformations for categorical variable encoding were done after the train-test split to ensure the training set remained independent.

The process for training was consistent across all models. A grid search was used with 5 cross validation folds for hyperparameter tuning. When the optimal parameters for each model were found the models were retrained on the full training set and then evaluated on the test set. The metrics used to evaluate the models were R^2 score and RMSE.

Summary of model evaluation results are below:

Lasso: R^2 = 0.9338

Ridge: R^2 = 0.9333

Elastic Net: R^2 = 0.9336

Random Forest: R^2 = 0.9113

AdaBoost: R^2 = 0.8454

Gradient Boost: R^2 = 0.9391

CatBoost: R^2 = 0.9421

Support Vector Regression: R^2 = 0.9491

Following the evaluation of individual models, the top 6 were chosen to be ensembled. The ensemble model took the average prediction across the 6 models to get a final overall prediction. The R^2 score of the final ensembled model was 0.9561.

Dashboard

Link to Tableau Dashboard

We designed a dashboard to create a tool for potential stakeholders to visualize the data and view sale price predictions based on customizable feature input values.

The dashboard was created in Tableau and utilized filters to sort and aggregate the data to make it easier for users to visualize trends. The dashboard allows users to easily group features such as โ€œNeighborhoodโ€ or โ€œ# of Bedroomsโ€ and the dashboard would return the average sale price for the applied filter. This tool is useful for potential buyers/sellers or realtors who can easily click and aggregate data for their needs.

We also created a โ€œPredictionโ€ tab that would use a linear model to provide a prediction for the price of a home based on certain features that a user could change (i.e: # of bedroom, bathrooms, etc). From the predicted home value provided, a user could determine if a home listed in the area is over/under market value based on the model.

Conclusions/Next Steps

This was a great first step into applying machine learning to the housing data set to make predictions for housing prices. There are areas we would love to revisit, rethink and add on to this analysis:

Next Steps:

  • The data was taken from 2006-2010, we would like to add data from 2011-2021 to have it reflect more current trends.
  • Add more complex models such as Neural Networks
  • Explore more models to add on with what we have, specifically creating stacked ensemble models that learn from previous models.
  • Increasing our feature input and predictive capability in the dashboard based on stakeholder feedback.
  • Add external data to add features to the analysis such as inflation, unemployment data, CPI, housing market trends, & other economic factors

About Authors

Hugh Goode

Hugh is a Data Scientist with a BS in Civil Engineering from the The College of New Jersey and an MS in Engineering Management from Duke University. After 5 years as an engineer, he pivoted to pursue Data...
View all posts by Hugh Goode >

David Jhang

David has 10+ years in the financial investment industry in NYC. He is currently working at a Long/Short Equity Hedge Fund that focuses on TMT. He is also currently an aspiring Data Scientist at NYC Data Academy.
View all posts by David Jhang >

Jung Lim

View all posts by Jung Lim >

Jack Copeland

After graduating from the University of Virginia in 2019 with a degree in Computer Science, I went on to join Anheuser-Busch as a Global Management Trainee. I received cross functional training in sales, marketing, supply and more before...
View all posts by Jack Copeland >

Related Articles

Capstone
Catching Fraud in the Healthcare System
Capstone
The Convenience Factor: How Grocery Stores Impact Property Values
Capstone
Acquisition Due Dilligence Automation for Smaller Firms
Machine Learning
Pandemic Effects on the Ames Housing Market and Lifestyle
Machine Learning
The Ames Data Set: Sales Price Tackled With Diverse Models

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