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 > Machine Learning > Using Data to Predict House Prices in Ames, Iowa

Using Data to Predict House Prices in Ames, Iowa

Victoria Lowery, Deborah Leong, Jay Cohen and Alexander Tin
Posted on Jun 7, 2020

The skills the authors demonstrated here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

Using Data to Predict House Prices in Ames, Iowa

  • GitHub Repository

  • Kaggle Competition

Overview

Our team worked on a Kaggle competition to use Machine Learning techniques to predict house prices in Ames, Iowa. While the data was fairly linear and our multiple linear regression models performed quite strongly, our team additionally explored tree-based models and gradient boosting to further fine tune our predictions. After our project deadline, our best-performing model, a Ridge-regression, earned a Kaggle score - Root Mean Squared Logarithmic Error (RMSLE) of 0.12509, which placed us in the top 13% of submissions.

Data Science Background

As we set out to determine which features of the house were the most important determinants of house prices, we first needed to familiarize ourselves and clean the 79 features provided. The features were a mixture of numerical data including the lotโ€™s area, basementโ€™s square feet, and the number of kitchens, in addition to categorical variables like the neighborhood, the type of sale, and even the roofโ€™s material. 

Early analysis explored the dataโ€™s missingness, redundancy, and skewness, among other facets, to best clean and engineer new features. With multiple cycles of analysis and engineering throughout the process, we implemented linear regression and classification models to find solutions to high dimensionality, outliers, and multicollinearity.

Data Exploration

Because the data provided so many features, we aimed our beginning-stage exploration at identifying predictive power. We looked specifically at low variance, redundancy, and missingness in individual features.

Using Data to Analyze Variance

When analyzing low variance, we found that multiple columns, for example โ€˜Alleyโ€™ (whether a home has an alley or not adjacent to the property), could be seen as a binary โ€œYesโ€ or โ€œNoโ€. The column โ€˜Alleyโ€™ contained all โ€œYesโ€ answers except for 91, only 6% of the data. Worse, only 32 rows in  โ€˜Heatingโ€™ held an answer other than โ€œGasAโ€.

Even still, only 7 homes recorded a โ€œYesโ€ in the โ€˜Poolโ€™ feature (whether a home has a pool or not), meaning 99.5% of the homes in our data do not have a pool. To include this particular pool column could potentially lead to an overfit model, since the feature is so heavily skewed to one side, โ€œNoโ€. While we could propose dropping such columns with extremely low variance, we could also move to use a penalized model like Ridge or Lasso to whittle down our excess of features.

Using Data to Predict House Prices in Ames, Iowa
Examples of low variance found in features 'Alley', 'PoolQC', 'Fence', and 'Heating'

Using Data to Analyze Redundancy

Next, our team took a look at features that might be redundant, those that could possibly be easily explained by another feature. First we compared โ€˜External Qualityโ€™, rated on a scale from โ€œPoorโ€ to โ€œExceptionalโ€, against the year the house was built, โ€˜Yearโ€™. As expected, the concentrated areas of each rating increase along the year scale as the rating increases. This would make sense as the older a home is, the more likely the exterior is to be weathered and aged from the elements. 

A similar trend was discovered when analyzing โ€˜Foundationโ€™ types across the decades. Before the 1940s, brick was often the foundation of choice; however between 1940 and 1990, cinder block swiftly became the material of choice. Then another swift shift in materials seems to occur around 1990, with nearly all homes having a foundation made out of poured concrete. 

Left: External Quality observed against the year built and the sale price.
Right: Foundation type against year built and the sale price.

The danger of redundancy is the loss of independence, one of the assumptions of linear regression. This could lead to highly inflated and misleading coefficients from an MLR model. Our team discussed options including throwing out possibly redundant features or instead choosing a penalized model to specifically target inflated coefficients from multicollinearity.

Using Data to Analyze Missingness

Missingness occurs when at least some of an observationโ€™s values are not present within the dataset. We set out to identify which columns contained missing values, and understand the patterns of missingness within those columns.

Features with missing entries

High Proportion of Missingness:

For the features 'PoolQC', 'MiscFeature', 'Alley', and 'Fence', there was a high proportion of missingness in these columns, with โ€œNAโ€s comprising of up to 99.5%, 96.3%, 93.7% and 80.7% of the column values respectively.

Values Missing at Random:

Values missing at random are when the data is dependent on variables for which we have complete information within our dataset. We identified that missingness within 'FireplaceQu' (Fireplace Quality) corresponded to houses in which the 'Fireplaces' feature was โ€œ0โ€ (i.e. the house does not have a fireplace). 'LotFrontage' appeared correlated to 'LotConfig', while 'GarageCond', 'GarageFinish', 'GarageQual', 'GarageYrBlt' corresponded to value โ€œNA - No Garageโ€ in 'GarageType'.

Values Missing Completely at Random:

Values missing completely at random are values in which the piece of data is neither related to observed variables nor related to the unobserved variables of interest. The missingness within features in relation to Basement ('Bsmt') and 'Electrical' did not seem to have any clear correlations to other columns within the dataset.

Data Cleaning and Feature Engineering

Now taking into account the information and patterns when visualizing and investigating the data, we conducted data cleaning and feature engineering to ready the data to feed into machine learning models for price prediction.

We expected a linear relationship in regards to the features of the houses in relation to the sale price (i.e. the larger the area of the house, or the higher the overall quality, the higher the sales price of the house).

Using Data to Analyze Outliers

In order to find the best fit line that is representative of the data, we also wanted to look at outliers which do not align with the values in the dataset. 

For example, we expect that as the living area of the houses increase, the sale price of the house will increase as well. However we identified two observations with large living area but unexpectedly low sale price. Oddly, these two observations also had a high overall quality rating, but did not correspond with a higher sale price. 

We decided to remove these two observations from the modeling set.

Using Data to Predict House Prices in Ames, Iowa
Example of outliers removed from data set

Using Data to Analyze Feature Manipulation

Depending on the model selection, manipulating the data types of certain features improved accuracy. For other models, the change was redundant and not necessarily needed. For example, โ€˜MSSubClassโ€™, a numerical category for dwelling type, held an int64 data type, yet the relation between code 20 homes, 1-story 1946 and newer homes inclusive of all styles, versus code 40 homes, 1-story with finished attic and all ages included, up to a score of 190 isnโ€™t necessarily a linear relationship that the numerical data type might force. For our linear regression models, we experimented with manipulating โ€˜MSSubClassโ€™ to a categorical type and dummifying the feature. This was not necessary, however, for our tree based models as it naturally treats each unique value as a category. 

Other features received the opposite treatment, shifting from an object to an integer. The features โ€˜ExterQualโ€™, โ€˜ExterCondโ€™, โ€˜BsmtQualโ€™, and others measured traits like quality on a ranked scale, from โ€œPoorโ€ to โ€œExcellentโ€. To provide a linear relationship to these ratings, informing the model that โ€œFairโ€ is closer to โ€œPoorโ€ than โ€œExcellentโ€, we manipulated these features into an integer type.

Using Data to Predict House Prices in Ames, Iowa
Some of the multiple features manipulated into a different data type
Using Data to Predict House Prices in Ames, Iowa
Missing values in 'GarageYrBlt' signaled absence of garage. However, missing entries in 'LotFrontage' required imputation.

Using Data to Analyze Imputation

Missingness in features like 'GarageYrBlt' (the year the garage was built) and the total 'Lot Frontage' (linear feet of street connected to property) required different treatments.

For the mentioned garage feature, if the home did not have a garage, there would be no year recorded for one to be built. We imputed a value of 0 to distinguish these homes as not having garages since the feature was an integer datatype. This imputation was less necessary for our tree models.

Missingness in the 'Lot Frontage' feature, however, appeared to be instances of absent data. To salvage these 259 lines, we grouped by 'Neighborhood' then binned a similar feature, 'LotConfig' (the configuration of the lot, e.g. a corner lot or inside lot), and imputed the respective average frontage to each missing entry.

Using Data to Analyze Models

Ordinary Least Squares

Using Data to Predict House Prices in Ames, Iowa
Simple Linear Regression: Train score against test score reveals overfitting

After taking the log of the target sale price, we fit a multiple linear regression model to our data. Because we had all features included, multicollinearity and an overfit model were expected. By taking the score of our train set and test set, we see this low complexity model resulting in a very wide difference between scores. 

Additionally, comparing the R squared scores of a feature against the rest, quite a few scores reach the top or come very close to a full score. This was yet another clue that certain features could be explained by others and that a penalization to our linear model was needed to reduce inflated coefficients.

Using Data to Predict House Prices in Ames, Iowa
One Against The Rest: The high R squared scores indicate multicollinearity, that certain features are already described by others

Lasso Regression

Because there were so many features, our team additionally tested a Lasso model to guide feature trimming. The graph below shows the significant drop of many featuresโ€™ coefficients, a sign their slope was greatly inflated from multicollinearity.

Using Data to Predict House Prices in Ames, Iowa
Lasso Regression: The significant drop of features' coefficients signal possible inflation due to multicollinearity
Using Data to Predict House Prices in Ames, Iowa
Lasso Regression: Lambda tuning using train and test scores

To find the best lambda, we found the cross where the model no longer overfits (the left side of the gray dashed line, where train scores perform well yet test scores do not) and before the model begins underfitting (the right side of the gray line, where test scores now outperform train scores). Here where the train and test scores converged we extracted our lambda. As the lambda parameter increases, the model slowly worsens in accuracy as the penalty defaults to the null model and removes any affect the coefficients added.

Random Forest

Using Data to Predict House Prices in Ames, Iowa
Feature Importance: 'OverallQual' for this particular model ranked highest in importance

While previously for our linear models we had taken the log of our Sale Price target, for tuning our Random Forest model we found the log transformation actually weakened the model. This may be that Random Forest is a nonlinear model and can handle far better a nonlinear relationship to the target.

Additionally, when we analyze the rankings of feature importance (see figure to the left), 'OverallQual' greatly surpasses every other predictor.

Gradient Boosting

Hyperparameter tuning quickly grew to a task fit better for grid search than manual manipulation. Previously Lasso and Ridge required a lambda parameter, the penalty; but for our Gradient Boosting model, parameters including number of trees, learning rate, maximum depth, and maximum features all needed testing. 

Below is a sample grid search performed for our gradient boosting model. With more time, our team would have hoped to tune and feature engineer further to strengthen the gradient boosting model.

Using Data to Predict House Prices in Ames, Iowa
A sample grid search run for our gradient boosting model

Final Results

Using Data to Predict House Prices in Ames, Iowa

While our tree-based models did not receive as much time with hyperparameter tuning and data manipulation as our linear models, they still quickly improved with only minimal tuning. Yet, our best scoring model remained one of our Ridge models. With more time we would have liked to explore stacked models and further strengthen our models to outliers.

For housing prices, human subjectivity ('OverallQual') was frequently the largest determinant. Following shortly behind overall quality were often features measuring square footage, but quite a few other subjective categories also made it to the top depending on the model. 'ExterQual' judged on a scale of 1-5 from โ€œPoorโ€ to โ€œExcellentโ€ the quality of the material on the exterior. This feature rising to the top of feature importance rankings implies home buyers are fairly swayed by outward appearances as well.

About Authors

Victoria Lowery

Victoria is a recent graduate of NYC Data Science Academy where she studied dashboard creation, machine learning, and statistical analysis. Her background of three years in the television and commercial industry allowed her to hone her organization and...
View all posts by Victoria Lowery >

Deborah Leong

Deborah is a data scientist with 10+ years of domain expertise in Asset Management. She's a Certified Public Accountant with acute acumen for financial data analysis and an avid painter with natural intuition in pattern recognition. She believes...
View all posts by Deborah Leong >

Jay Cohen

View all posts by Jay Cohen >

Alexander Tin

View all posts by Alexander Tin >

Leave a Comment

Cancel reply

You must be logged in to post 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