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 > Python > Machine Learning Project: EDA and Customer Segmentation in Ames, Iowa Real Estate

Machine Learning Project: EDA and Customer Segmentation in Ames, Iowa Real Estate

Liliya Lopez
Posted on Mar 13, 2023

Introduction

If you are reading this blog, you are more likely familiar with one of the most popular machine learning competitions from Kaggle, predicting house prices in Ames, Iowa. You can find countless amounts of work done on this topic online. For this particular project, I used both supervised and unsupervised methods however mostly focused on the marketing aspect by using the clustering technique. So, without further ado letโ€™s get started!

Datasets

I used two datasets for this project. The Ames House Price dataset was collected from Kaggle.com and can be found by clicking this link. 

The State of Iowa Salary Book dataset was collected from the data.iowa.gov website and can be found here.

Exploratory Data Analysis with Machine Learning Methods

First, I started with Exploratory Data Analysis potentially to identify what features of the Ames housing dataset increase the sale price. For this step, I replaced Great Living Area with Total Living Area feature by simply adding 1st Floor, 2nd Floor, and Finished Basement square footage variables. Also, I engineered a new Aggregated Bathroom feature by adding Full Bathroom, Half Bathroom, Basement Bath, and Basement Half Bathroom variables. I used the code below to visualize the correlation between numerical features and Sale Price:

According to the results, these are the top five features that correlate with Sale Price:

  1. Overall quality
  2. Total Living Area square footage
  3. Total Basement square footage
  4. 1st Floor square footage
  5. Aggregated Bathroom count

Another great way to identify what variables influence the sales price, is to extract feature importance attribute from the random forest. This can be achieved by following these steps (make sure to label encode categorical features before fitting a model):

If we take a closer look at the top 10 predictive features influencing the sale price, we will find variables such as quality, square footage, bathroom count, year built, and neighborhood. As expected, these properties make residential real estate more attractive to buyers.

I visualized some of the most important features that affect the home's sales price.

House Overall Quality

Box plot is easiest way to represent the relationship between house overall quality and the price.

Overall house quality was the most important factor in correlation and feature importance attribute for numerical variables. From the box plot above, we can observe that on average the houses with the quality index 10 were sold for approximately  $380,000 to $530,000 versus houses with the quality index 1 and 2 sold for less than $100,000.

Total Living Area Square Footage

Total Living Area square footage is another important factor that can positively impact a real estate property's price value. As I mentioned before, this feature was engineered by adding the square footage of the 1st and 2nd floor along with the square footage of the basement making it the home's usable living space. It excludes square footage of garages, attics, lot areas, and unfinished basements.

According to the scatter plot above, there is a positive correlation between the total living area and sales price meaning that buyers in general are willing to pay more for the usable square footage. After running the simple linear regression in sklearn, I found out that the coefficient of determination for those two variables is 0.60 meaning 60% of the variance in sales price is predicted by the total living area.

Year Built

Another factor I thought worth mentioning is the year built. To best visualize the relationship between year built and sales price, I decided to break houses into 3 categories: 1) houses built before the 1990s and not remodeled, 2) houses built before the 1990s and remodeled, and 3) houses built after the 1990s. The density plot below represents the effect of the year built on the sales price.

According to the density plot, we find that houses that were built after the 1990s tend to sell at higher prices.

Customer Segmentation Analysis

As I mentioned above, I used the State of Iowa Salary Book dataset for customer segmentation analysis. It contains information such as the name, gender, county official title,  total salary received during a fiscal year and etc. of Iowa residents. After filtering the dataset by place of residency, I found that Ames is located in story county. It turns out that Iowa State University and the Department of Transportation are the two largest employers in story county. A fun fact is the salary paid in Ames ranges from $1,000.49 earned by students to $2,375,000.04 earned by a head coach in 2020. I narrowed down the total salary paid feature from $35,000 to $917,499.98 for this project. According to the histogram below, we find the right skewed salary distribution.

Feature Engineering

For this project, I segmented potential home buyers by utilizing the total salary paid feature. To find out "what house price can I afford", I engineered additional three variables derived from the residents' income:

  1. Monthly payments: the general rule states that an individual should spend around 28% of monthly income on a mortgage payment. Monthly payment = (Annual Income/12)*0.28
  2. Loan Amount: we make an assumption that the mortgage terms are 30 years and 6%. Loan amount = (payment*(1 - (1+rate/12)**(-months)))/(rate/12)
  3. Home Price: we make an assumption that a 20% down payment is required for a mortgage loan. Home Price = (Loan Amount*0.1)/0.08

Keep in mind that you will need to consider the other factors in the real-life situation such as property taxes, insurance, and credit score of a potential home buyer.

If we plot the total salary paid versus the home price in a scatter plot, you will find a perfect correlation. The reason why we got the clean results is that the home price was directly derived from the salary feature. In this case, the home price feature is the estimated number we use to determine affordability.

K Means Clustering

K-means clustering is one of the most popular unsupervised methods in machine learning. I used the elbow method to find an optimal number of clusters, which is graphically represented below:

According to the graph above, I found that k=5 is the optimal number for clustering meaning that we are going to segment our potential home buyers into five different groups and visualize the results.

Conclusion

Based on these results, you can build a marketing strategy by targeting a specific demographic. For instance, you can advertise the homes with a price range from $170,266.25 to $369,793.75 to the cluster 1 group by offering real estate with house quality 5 to 8, a total living square footage from 988 to 4676, and year built from 1879 to 2010.

I hope this blog was helpful. You can find the complete code for this project on GitHub.

About Author

Liliya Lopez

Dedicated professional with comprehensive skills in quantitative science, analysis, research, predictive models, and working with cross-functional teams to achieve goals. Known as an innovative thinker with statistics, data analytics, R and Python development, visualization, machine learning models, and...
View all posts by Liliya Lopez >

Related Articles

Capstone
Catching Fraud in the Healthcare System
Data Analysis
Car Sales Report R Shiny App
Data Analysis
Injury Analysis of Soccer Players with Python
Capstone
Acquisition Due Dilligence Automation for Smaller Firms
R Shiny
Forecasting NY State Tax Credits: R Shiny App for Businesses

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