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

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


Our Recent Popular Posts


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