Maximizing Home flipping profits using ML Techniques.

, and
Posted on Feb 5, 2023

See our app here

Home-flipping is becoming more and more popular as investors are finding unique ways to capitalize on their returns. As it turns out, however, 20% profit is considered the break-even point. As a result, over 28% of home-flippers end up losing money. In order to be successful at home-flipping, one must be able to conduct thorough research in order to make fiscally smart decisions. Throughout this blog, we’ll be demonstrating various machine learning techniques that can help us make informed decisions about which properties to purchase and which improvements generate the highest return on investment (ROI).

Data Preprocessing

The analysis uses two different datasets: one provided by Professor Dean De Cock (Housing, Ames) and another by Kaggle (Real Estate, Ames). The first dataset is the primary dataset, which contains 2500 observations and 78 features. The homes span over 28 neighborhoods in Ames, IA in 2006-2010. The second dataset contains 22.5K observations and is used to geographically visualize where the homes are with respect to their coordinates.

Before any analysis could be done, the data must first be cleaned. Not all missing values are expected to be non-existent, so some work needed to be done to address those missing values. We started by identifying which features contained missing values.

NaN values relating to area (TotalBsmtSF, GarageArea, MasVnrArea) were addressed first and filled with 0. Then, features containing NaN relating to these groups were filled with 0 if its respective area were also 0. This was able to address a significant chunk of the NaN values in the dataset. Other categorical NaN values were filled with the most common value attributing to that feature. For continuous NaN, such as GarageYrBlt, the most common value is the YearBuilt.

Four new features were added to the dataset (Crime Rate, Public Schools, Neighborhood Appreciation, and Neighborhood Income). These features were taken from and added in respect to the geographical coordinates of the merged dataset. These features contain ordinal values ranging from 0 to 10.

Additionally, 2 features were engineered from existing features with the latter being dropped after:

  • HouseAge = YrSold – YearBuilt
  • LastRemod = YrSold – LastRemodAdd


Model Preprocessing

The preprocessing of the data varies between the type of model used.

For linear models, categorical features were separated into ordinal and nominal variants. Nominal variants were then dummified. To remove multicollinearity among the features, a correlation matrix was used to identify the correlation between two features. Features with high collinearity with each other were dealt with by selecting the more important feature of the two. 

Once all features had low correlation individually, a VIF was conducted to investigate each feature's correlation with all other features. A for loop was then conducted to slowly remove each feature and list VIFs until features had a VIF score of 10 or less. The final data was then scaled in respect to its mean and standard deviation using a Standard Scaler.

For SVR, tree-based models and our final stacked model, categorical features were separated into ordinal and nominal variants. Nominal variants were label encoded. Aside from Random Forest, the data was also scaled in respect to its mean and standard deviation using a Standard Scaler. 

For the time series analysis model, a DateSold feature was engineered from YrSold and MoSold. The first of each month was chosen (e.g: a home sold in February 2008 yielded the value 2008-02-01). The mean of each month was then chosen as the final datapoint for time series analysis.


The where & when.

A key driver to a successful home-flipping is timing. In order to maximize profits, it’s necessary to know when to buy and sell a home. To achieve that, we first explore a broadened view of home purchase annual frequency.



When analyzing the chart above, it’s clear that seasonality exists. As demand starts to pick up in the summer months, we can presume that higher prices will follow suit due to the lower supply. However, there are many caveats to that: for instance, inventory in the summer months could be significantly higher due to an influx of seasonal listings. This, coupled with warmer weathers, higher levels of tourism, and many other factors could mean that the high summer demand could meet an equally high seasonal supply.

Seasonality isn’t the only factor to home prices. When analyzing how well a home fares within a community, it’s important to also capture the overall trend. After all, the prices of homes may differ from one year to the next.


Decomposed Trend & Seasonality

To conduct proper analysis, we must first decompose the trend and seasonality from the data. In the graph above, the top-most plot represents the original prices of homes sold through time. The second graph represents the extracted trend and the third graph represents the extracted seasonality.

If we account for seasonality alone, then flippers should aim to buy in March and sell in January when prices are the lowest and highest, respectively. However, as it’s unlikely that flippers can close a home purchase in a single month, it’s more feasible to aim to buy a home in February – April and sell within June – August.

When inspecting the trend alone, we can see that the home prices contain a general downward direction. While subtle, the trend started to pick up and shift throughout 2009, which is the height of the Great Recession. However, we’d be naive to think that every part of Ames follows a similar trend.



In fact, the prices in some neighborhoods remain stable throughout the recession, though some fared significantly better than others. Shown above, these neighborhoods had been given a trial by fire and had proven to be more resilient than others throughout the great recession. As the recession starts to ramp up during 2023, these neighborhoods are premium neighborhoods and should be given higher priority than others when looking to buy a home within Ames.



When adjusting for the seasonality and trend, we can then forecast the sale prices for the next few months following the recession. By doing so, this can give us a more defined perspective on the best time to buy and sell a home, which could help maximize the investment.


The what.

When determining what to look for in a home, we first tune into various models and its respective performance. Using Lasso Regression, we were able to reduce the features in the model to 35 while maintaining a fairly high test score (0.920). Non-linear models, such as Random Forest, Gradient Boost, and SVR were also used to rank model feature importances. Afterwards, we applied a stacked regression model to combine nonlinear models in order to extract the top feature importance based on multiple models.

In each model, the features were ranked according to their importance. In cases where the model doesn’t have a feature importance method, such as penalized regression, the absolute value of the coefficients were used to rank the model’s importance. Once sorted in order, a for loop was conducted in order to reduce the number of features one by one and capture the number of features to the regression score.


Model Performance vs. Features


While each model behaves differently, it’s shown above that the models start to plateau around 30 features, with most models able to capture the Sale Price of a home with about 10-15 features. In other words, 30+ predictors increased the complexity of the model while providing almost no additional value.

A summary of the models used and their results are captured below.



The how.


Using our final Stacked Model, the most important features are ranked as shown below.


In order to maximize profits, the features to select should be the ones with the highest importance relative to the stacked model. In other words, a successful home-flip should do the following:


  1. Focus on building structure. Choose single-story homes with potential to expand upwards in order to increase the GrLivArea. This will give the highest opportunity to maximize living area while keeping lot size small.
  2. Look for worn-down homes with good building material quality. It’s easier to touch up the OverallCond than the OverallQual. Therefore, aiming to buy worn-down great quality homes would ensure that you’d be buying at a discount!
  3. While it may be difficult to increase TotalBsmtSF, the feature is moderately correlated with BsmtQual and BsmtCond. Therefore, using the same points as above, we can focus on finding homes with great basement quality in a worn down condition.
  4. While it may be helpful to look at the forecasted chart for the optimal buy/sell target, a general consensus would be to buy in February – March and sell in June – August.
  5. Aim to buy homes in neighborhoods that have been proven to have fared well against the last recession. These neighborhoods are more resilient than the other neighborhoods, and that should play a significant factor when choosing the next home.


Happy flipping!


About Authors

Daniel Setiawan

Hi, I'm Daniel! I currently work as an R&D Engineer at a startup in Berkeley, CA. In my role, I interface with various electronics (RF/DC) and code (Python) to analyze and improve product performance. I’m intrigued by science...
View all posts by Daniel Setiawan >

Laurel He

Hi, my name is Laurel He. My undergrad was in Geosystems Engineering and Hydrogeology at the University of Texas at Austin. I got my Master’s in Atmosphere and Energy, Civil Engineering at Stanford University. I’m passionate about nature,...
View all posts by Laurel He >

Daniel Erickson

I'm received my Ph.D in mathematics from Oregon State University. I enjoy tackling complex problems - specifically those amenable to insight gleaned through data.
View all posts by Daniel Erickson >

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