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 > Meetup > Optimizing Real Estate Price Prediction with Clustering for Haystacks.AI with Alternative Data

Optimizing Real Estate Price Prediction with Clustering for Haystacks.AI with Alternative Data

laurentomlinson
Posted on Oct 10, 2022

Project was in collaboration with Trevor Mattos

TLDR:

 

Partnered with PropTech company Haystacks.AI, we used real-life property data in Georgia to optimize property valuation using machine learning. We scraped additional features and alternative data (walk scores, grocery stores, schools). We implemented the haversine distance equation to get the distance to each amenity to add as a feature. We then ran PCA to get 3 principal components, then used k-means clustering to identify which cluster each property belonged to based on these principal components. We then added  โ€œclusterโ€ as a new feature in a linear regression model to see if it would perform better than the control (model with no clustering information) to see if it improved  model performance- to which it did.  We then subset the data to a smaller scale (Only Atlanta  vs looking at the  entire state) to find that this improved the  model performance even further.  

 

Figure 0: ( Top Left) Clear emergence of clusters in data, graphed by component 1 (C1), component 2 (C2), and component 3 (C3). ( Top Right) Pearson correlation heat map showing which factors are most strongly prevalent in each component: C1: crime; C2: General property info; C3: Distance to amenity. (Bottom) Clusters after  k-means on the Atlanta subset.

 

Overview 

 

The real estate market is uncertain and can be difficult to navigate, often riddled with issues like property valuation and the occurrence of market patterns/trends that are difficult to uncover. Machine learning can alleviate such issues, with algorithms like clustering that can help us identify trends and  group properties based on similarities that may affect property value- like walk scores or distance to certain amenities. Supervised models can then use the information gained from clustering to aid in property valuation as well. Here weโ€™ll work together with Property Technology company, Haystacks.ai, to see how clustering algorithms can uncover natural groupings in real-estate data, then use the groupings  to optimize property price prediction.

 

Data Cleaning and Feature Engineering

Haystacks.ai assists Single-family rental (SFR) investors with identifying properties to invest in to maintain a competitive and optimized real estate portfolio. The company provided us with scraped data from the entire state of Georgia, with some basic features on single-family rental properties:

Figure 1: Original dataset provided by Haystacks.ai with basic information about properties in Georgia.

 

After some basic data cleaning (imputing missing values, removing outliers) weโ€™re left with around 11,500 properties to analyze.Now that we have a cleaned data set that is ready for analysis, we can do a quick 3D plot to see if thereโ€™s any intuitive looking clusters:

 

 

   

Figure 2: Graph of properties in Georgia based on 3 numeric features 

 

As is evident, no intuitive clusters appear in the given data. Luckily, we have a few tactics that may aid in  the formation of clusters. We used both Google API and beautiful soup to scrape additional features such as walk score, schools, location of banks, location of schools, and some features that are indicative of gentrification- like the occurrence of grocers such as Trader Joes and Whole Foods. We were also able to find some Georgia crime rate data at the zipcode level. 

 

Once the data is merged, we can pretty easily implement the haversine formula to calculate the distance from each property to the nearest amenities, then add the results as features as well. 

 

Figure 3: Haversine formula. We can find the distance between any two points on a sphere, converting points to lat long  and the radius of earth can give us the distance of any two points on the globe. 

 

Clustering Algorithms Into Supervised Methods

 

Now that we have a heftier set  of features, we might begin to see some clusters. To account for the curse of dimensionality, we can run Principal component analysis (PCA) to reduce our features to something easy to visualize- 3 principal components. 

 

Figure 4: Clear formation of clusters. The correlation plot on the right can give us information about how to interpret the axis: C1 shows information on crime rates, C2 on general property features, and C3 shows distance to desirable amenities. 

 

Since we have some nice looking data, we can use a clustering algorithm like K-means to group similar properties together. We use a quick for-loop to estimate what amount of clusters will give us the highest silhouette score, in our case n=3. Once we have our beautiful clusters, we can use this information to subset into 3 separate models to run supervised methods on:

 

 

Figure 5: Data with color = Cluster. Data is then subset by cluster labels, resulting in 3 models ready for linear regression.   

We can compare these models to a control group to test if giving supervised machine learning models information about clustering improves price prediction. The control group consisted of the following features: beds, baths, square footage, year built, distance to school, distance to quality grocer (Whole Foods, Trader Joes, etc), distance to bank, and violent crime rate, with the target variable set as price. Weโ€™ll be looking at R^2 to score each model out of the box (without hyperparameter tuning) to test performance. The control group scored about R^2 = .48, model 1 scored R^2 =.45, model 2 scored R^2 = .65, and model 3 scored R^2 = .45, with an average of the 3 modelโ€™s performance standing at R^2 = .52. While the models with information about clustering did average a slightly higher score than the model that did not have the clustering information, Itโ€™s clear and intuitive that the models with greater data separation lead to better price prediction. Since we have access to latitude and longitude, what would happen if we plotted the experimental models on a map of Georgia? 

 

Figure 6: Geographical distribution of 3 clusters: Model 1 =โ€Outer ring clusterโ€, Model 2 = โ€œDowntown clusterโ€, Model 3 = โ€œInner ring clusterโ€

 

Our clustering algorithms were able to correctly identify and cluster which properties geospatially belonged together, without being given any information on latitude or longitude. The best performing cluster correlates to the downtown cluster, which makes sense as it would have different property valuations compared to the more suburban areas surrounding it. 

 

Similarly, when looking at property data across a whole state the density can be difficult to parse through correctly since each local niche market values different things. What would happen if we subset the data to only look at Atlanta, Georgia?

 

Looking at just properties in Atlanta, Georgia, we follow the same algorithm: we take the Atlanta subset, run PCA, feed the 3 principal components to k-means, get the labels for the clusters, subset on the clusters, then run simple linear regression on the experimental models and control groups and compare out of the box R^2 scores to see if the clustering information helped supervised model performance. 

Figure 7: Clusters of properties in Atlanta, Georgia with color = Cluster. The data is then subset into models based on cluster labels. 

 

We again score each model by looking at R^2, with the target variable being price. The control group scored around .70, model 1 scored around .65, model 2 scored around .80, and model 3 scored around .72 (average of the 3 experimental models: .72). Itโ€™s clear that crime rate seems to have a huge impact on price, and identifying areas of extreme (very high crime, very low crime) can help us to better predict property price. 

 

Conclusions

 

As we have seen, clustering information can in fact increase a supervised modelโ€™s price prediction ability. Clustering proves a promising method in the field of real estate, with the ability to provide investors a competitive edge in their real estate portfolios by gaining pricing power and to obtain desirable properties (i.e. minimized distance to amenities). Clustering can also have implications in property valuation by helping to understand niche local markets, and by feeding clustering labels to supervised models to enhance price prediction performance. The supervised methods can then aid in property valuation, and help investors decide to invest in a property and how to offer it at an optimized price.

 

 

Github: https://github.com/trevaveras/Unsupervised-Learning-RealEstate

 

 

Resources

https://www.xenonstack.com/blog/real-estate-investment

https://towardsdatascience.com/principal-component-analysis-algorithm-in-real-life-discovering-patterns-in-a-real-estate-dataset-18134c57ffe7

https://towardsdatascience.com/dbscan-clustering-algorithm-how-to-build-powerful-density-based-models-21d9961c4cec

https://gisdata.fultoncountyga.gov/datasets/adef0a906333496c931c56c3875c7af6_316/about

 

About Author

laurentomlinson

Master's student studying Bioinformatics at NYU with a passion for Data Science
View all posts by laurentomlinson >

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