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 > Student Works > Property Data Analysis I: House Prices in Iowa

Property Data Analysis I: House Prices in Iowa

William Ponsonby, Mikolaj Wilk, Kyle D. Weber and Michael Griffin
Posted on Dec 6, 2019
The skills I demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

The 60 second summary

  • House prices in Ames, Iowa can be predicted to ~ +/-12% accuracy using models with 80+ factors
  • Heuristics are not the best guide for prices but simple models can provide good accuracy
  • Complex models and stacking can be used to obtain a top 15% Kaggle score, but this comes at the expense of overfitting risks and reduced transparency
  • For data science projects as part of a small team, a modular approach with upfront investment in feature engineering and functional programming can pay dividends

Aims for Ames

We are trying to predict house prices in Ames, Iowa using a training ~0.5MB dataset with around 1500 observations and 80 variables. (The associated Kaggle competition describing the data set and target variable in more detail can be found here.) The variables included in the data set include information about the size, quality, location, and features of each property and the conditions surrounding its sale.  In line with the rules of the associated Kaggle competition, we did not enrich the data provided with additional outside information.

From the outset, we had three related objectives in mind:

  1. To design a simple model that could identify which factors explain local housing prices in Ames
  2. To build a model using more complex modelling techniques that could further reduce our prediction error 
  3. Find an efficient strategy for working collaboratively across a pipeline

Our forecasting metric is the root mean squared error on the logged sale price (RMSLE).  Using this metric means we view a 1% error on a 150k and 300k house to be equivalent.

Team Approach

We are a team of data scientists with complementary backgrounds in economics, science, finance and linguistics.

We recognised that we would need to transform and process the core data for both the simple and optimised model, so we needed to set up a flexible โ€œpipelineโ€ without segregated data sets and notebooks.

This pushed us towards a more modular approach, where data processing steps are designed as functions which can be repeatedly called rather than using one-off processing steps.

Data cleaning and feature engineering

There are a few distinct considerations that dictated our approach to data cleaning and feature engineering.

The first aspect of this project that influenced our approach is that the training set only contains around 1500 rows. While this simplifies the process of loading, manipulating, and modifying this data set, it creates an additional challenge of avoiding overfitting given that the test data set is roughly the same size as the training data set. To avoid overfitting, our approach was to generate validation data sets that could be used to test model performance and fit hyperparameters that would then be used to estimate predictions on the test data set.  

Our approach to data cleaning and feature engineering was also influenced by the fact that different approaches to encoding categorical data and imputing data were needed to estimate separate tree and linear models.  On top of this, there were a number of modeling decisions (e.g., How to drop outliers? Whether to square or log certain variables?) where there was no clear answer a priori and so we wanted to determine which data cleaning approach produced the best results.

Given these concerns (and our desire to ensure that train/validation/test data sets were modified in equivalent ways), our group spent extra time designing a function that would generate the required number of data sets and modify them using the procedures defined by the functionโ€™s parameters.  We found that this approach was very helpful in making code easier to read and allowing us to easily and empirically test how different data cleaning approaches performed when modelling on the validation data set.

Feature engineering

One last aspect of our feature engineering approach that is worth commenting on is how we decided which new features we wanted to add to our data set. While some new features were identified through introspection, a number of features were identified by combining information from multiple variables that were found to be strongly correlated. 

For example, various quality measures were found to be closely correlated, which led us to generate a single average quality measure as well as counts of the number of variables in different quality categories to incorporate information from multiple different categorical variables into a more parsimonious number of variables.

We found dendrograms particularly helpful in visualizing the clustering of different variables based on their respective correlations, with groups of variables that were particularly correlated with each other appearing clustered together. This approach allowed variables that could be combined into a smaller number of derived factors to be easily identified.

Modeling approach

To get a sense of what baseline level of forecasting performance might be achieved using very basic statistical techniques and some baseline knowledge of the housing industry, we ran a non-regularized OLS model using a series of intuitive features. After some discussion, our group decided that we could best approximate the knowledge of a domain expert by looking at which sources of information were commonly reported on multiple real estate comparison and advertising sites.

After identifying ten features of this type (and turning these features into a total of 44 variables), we were left with a model whose prediction performance would serve as our baseline. Our average cross-validation RMSLE was 0.16 and our test RMSLE was 0.15, which made this model the only one that we examined that performed better on the test data set than the cross-validation data sets.

While this indicates that our baseline model was not subject to overfitting issues, we were confident that we could do better (and we were even able to identify a linear model using Lasso that performed better while including far fewer features).

Outset

From there, we started modeling immediately so we could see from the outset which models would work best. We explored linear models such as Ridge, Lasso and Elastic Net. The nature of Ridge is that the coefficients never in fact reach zero so one keeps all of the predictors fed into it whereas Lasso will cull superfluous predictors.

Given that we were attempting to create a high performing model with relative transparency, keeping irrelevant predictors from the 80 odd variables in the original dataset would not be ideal, not to mention after weโ€™d added new variables through one-hot-encoding and feature engineering. Lasso outperformed Ridge prior to pre-processing anyway so it was an easy decision to move forward with Lasso. Elastic Net, which tries to find a happy medium between Ridge and Lasso, had similar results to Lasso, but for the sake of simplicity we proceeded with Lasso.

Model

We wanted to see how accurate a model could be with minimal predictors. A heavily penalized Lasso model with only 9 predictors scored a cross validated RMSLE of 0.17 which was slightly worse than the intuitive OLS on heuristics albeit with fewer variables.

We found that the optimal number of predictors after feature engineering and one-hot-encoding was 80, ironically the same number of variables that we started with. However, this was in fact only 20% of the variables that we fed into the Lasso model. This model scored a competitive 0.1202 on the Kaggle test set, fulfilling our primary goal to create a high performing and parsimonious model. 

We also explored nonlinear tree models, in particular random forests and gradient boosting techniques.  These proved to be useful out-of-the-box as less data engineering is required; in particular random forests offered a quick way to assess variable importance and test out new features.

Model stacking

Our initial feature engineering modelling efforts produced good results - but to achieve our secondary goal we needed to explore some more sophisticated modelling techniques. It is common practice on Kaggle to use model ensembling/stacking - we investigated two approaches to model stacking which we refer to as parallel and sequential stacking. 

Parallel stacking is the idea that we could combine our separately trained models to produce an overall estimate where noise and overfitting is cancelled out. However, not all of the residuals in a model are due to noise so there is a danger of diluting the good performance of our Lasso model with other worse performing models. There is also the question of how to weight the stacked model, with potentially extra weighting on a particular model.

Running all five of these models with cross validation and various different weightings on each model would take ages. Our best performing parallelly stacked model was with Lasso and Gradient Boosting, however, this approach did not improve on Lasso on its own so we changed tack. An illustration of the parallel stacking approach is shown below:

Through a sequential stacking approach, we hoped to take the strong results of our linear model and fit another model, a Random Forest, to capture any patterns in its residuals. This would allow our second model to limit the effect on our RMSLE of house prices which the linear model predicted poorly. 

One pitfall which we had to be careful of was overfitting the residuals and capturing noise rather than signal. Empirically we found sequential stacking to be an effective way to reduce issues with outliers whilst maintaining a parsimonious model. An illustration of the sequential stacking approach we took is shown below:

Below is a comparison of the Kaggle scores for these two approaches:

Conclusions and future work:

While our group is generally satisfied with our modelsโ€™ forecasting performance and our teamโ€™s general approach, we have a few ideas about how we might improve our final product.  

First, given the general success that we had implementing a functionalized approach to feature generation and data cleaning, we think that we can make our existing code base faster, more readable, and easier to re-use by applying this approach to model estimation and visualization.  

Second, we found that much of our tree modelling (particularly tuning parameters for the gradient boosting modelling we performed) took a significant amount of time and limited our ability to either use our local machines or our shared Kaggle kernel for significant lengths of time.  Instead, we would ideally like to set up a Docker image with all of the files and Python modules needed to perform our analysis that could then be run from a high-performance AWS cluster to reduce the time required to edit and run our existing code.  

Finally, one advantage that we had for modelling Iowa housing prices was that our test and train data sets covered relatively similar homes. This is evidenced by the fact that only seven of our 80+ features had significantly different distributions at the .15 level in the train and test sets (as measured using the Kolmogorov-Smirnov statistic for numerical data and a Chi-squared test for categorical data).

In our next project, we wish to generate prediction cases where the test data looks extremely different from the training data to get a better sense of the challenges that come from this form of prediction. This would, for example, be a huge concern for forecasting data one year using observations from another year. 

 

About Authors

William Ponsonby

William Ponsonby is a data scientist currently studying at the NYC Data Science Academy. Prior to that he studied Russian, Czech and Slovak at Oxford University and did internships in Investment Analysis, Accounting, Advertising and Self-Storage in London,...
View all posts by William Ponsonby >

Mikolaj Wilk

Data Scientist, Developer, Scholar and Scoutmaster with a background in Physics, determined to unlock business value and solve problems with analytical and data-driven methods.
View all posts by Mikolaj Wilk >

Kyle D. Weber

Kyle D. Weber is currently training at the NYC Data Science Academy to gain additional proficiency with machine learning techniques, SQL, Python, and database management tools such as Spark, Hadoop, and Hive. He holds a Masters of Philosophy...
View all posts by Kyle D. Weber >

Michael Griffin

Mike Griffin is training at the NYC data academy and has several years of experience in strategy/analytics roles in finance. He studied Natural Sciences (Physics) at the University of Cambridge and Management at the Judge Business School. Mike...
View all posts by Michael Griffin >

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