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 > Analyzing Data to Predict Real Estate Value in Ames, Iowa

Analyzing Data to Predict Real Estate Value in Ames, Iowa

Leba Wilamowsky
Posted on May 11, 2021
The skills I demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

Github Repository

Introduction

There are many factors that determine the worth of a piece of real estate. For this project, I used The Ames Housing data set, compiled by Dean De Cock, to predict home prices in Ames, Iowa. Real estate has always been an interest of mine, so I had some background knowledge coming into this project. I actually interned for a real estate company in the summer of 2020 and very much enjoyed it.

My goal was to create different models, find the model that best predicts housing prices, and then analyze the best model to gain insight into what features are important in changing real estate value most significantly.

Data Cleaning

I started by dealing with the null values in the dataset:

  • A lot of the null values in the dataset were easy to impute because they were missing due to the house lacking that feature. For example, I changed the null values in โ€œBsmtQualโ€ to โ€œNoBasementโ€ because the null values meant that the house didnโ€™t contain a basement.
  • There were some features containing very few observations with null values, and the reason why wasnโ€™t clear, so for those I imputed the mode or mean.

 

Data on Feature Engineering: Removing Features

There were certain features that I took out right away, as they wouldnโ€™t be fair to use for modeling. Some features, like โ€œStreet, โ€œUtilitiesโ€, โ€œRoofMatlโ€, โ€œHeatingโ€, and โ€œLowQualFinSFโ€, were taken out right away, because at least 99% of observations had the same values for these categories.

"Both Conditions" Data

I combined โ€œCondition1โ€ and โ€œCondition2โ€ into one feature called โ€œBothConditionsโ€, for a more accurate model. It wouldnโ€™t make sense to keep them separate because some houses could have a certain condition listed under the feature โ€œCondition1โ€ and another house could have that same condition listed under โ€œCondition2โ€, so it wouldnโ€™t make sense for the model to split the conditions into two separate features. The categories with high enough amounts of observations to be useful for modeling all have similar distributions. So, I did not use this feature. The rest of the categories didn't have a significant enough number of samples for purposes of modelling/analysis.

Analyzing Data to Predict Real Estate Value in Ames, Iowa

Features Not in The Graph

  • โ€œLotFrontageโ€, i.e. linear feet of street connected to property- too many missing values
  • โ€œAlleyโ€, i.e. type of alley access to property (gravel v paved v no alley access)- based on common knowledge itโ€™s not a significant feature for real estate price, and far majority of the houses have no alley access
  • โ€œYearBuiltโ€- Itโ€™s a redundant feature because the feature
  • โ€œYearRemodAddโ€ lists the year the house was built if it wasnโ€™t remodelled. What is significant to the real estate value is the last time the house was remodelled, so we only need the โ€œYearRemodAddโ€ column.
  • โ€œMiscFeatureโ€- Far majority of the features donโ€™t have a value in this category, and the most common one, shed, doesnโ€™t correlate with a certain sale price anyway. So thereโ€™s no use in using this feature to determine sale price.
Analyzing Data to Predict Real Estate Value in Ames, Iowa
  • โ€œLandSlopeโ€, โ€œBsmtFinType1โ€, โ€œBsmtFinType2โ€, โ€œExterCondโ€, โ€œElectricalโ€, โ€œMiscValโ€, โ€œMoSoldโ€,โ€YrSoldโ€,โ€œFunctionalโ€, โ€œGarageQualโ€, โ€œGarageCondโ€- I plotted catplots and they showed to be not useful in determining sale price. In โ€œExterCondโ€ one category seems to have a lower mean sale price, but this is not a valid observation to take into account because there arenโ€™t enough observations in this category for a valid analysis.

Catplots Data 

Analyzing Data to Predict Real Estate Value in Ames, Iowa
  • โ€œBsmtFinSF1โ€, โ€BsmtFinSF2โ€, โ€œ1stFlrSFโ€, โ€œ2ndFlrSFโ€- I didnโ€™t use these features because we already have a different feature that tells us the total square footage of the basement, โ€œTotalBsmtSFโ€, and a different features that tells us the total SF above the basement, โ€œGrLivAreaโ€.
  • โ€œGarageYrBltโ€, GarageCarsโ€, โ€œTotRmsAbvGrdโ€- Based on common sense I assumed that โ€œGarageYrBltโ€ would be highly correlated with โ€œYearRemodAddโ€, as โ€œYearRemodAddโ€ is the year the house was remodeled if it was; otherwise it is the year the house was built. Likewise, based on common sense, I assumed that โ€œGarageCarsโ€, i.e. size of garage in car capacity, would be highly correlated with โ€œGarageAreaโ€, i.e. size of garage in square feet. Additionally I assumed that โ€œTotRmsAbvGrdโ€, i.e. total rooms above grade (excluding bathrooms)โ€ would be highly correlated with โ€œBedroomAbvGrโ€, i.e. total bedrooms above grade. I confirmed my assumptions with scatterplots, and did not use the features โ€œGarageYrBltโ€, โ€œGarageCarsโ€, and โ€œTotRmsAbvGrdโ€ due to the idea of multicollinearity.
  • โ€œExterior2ndโ€- >95% of the observations had the same exterior material listed in both โ€œExterior1stโ€ and โ€œExterior2ndโ€, so I just used โ€œExterior1stโ€ to avoid redundancy. I didnโ€™t combine the two of them into one feature because it would create too many categories each consisting of very few observations, and hence complicate the modelling. The catplot showed Exterior1st as a useful feature in determining pricing.

 

Data on Feature Engineering: Keeping Features

Certain features were obvious to keep, by definition of what real estate pricing is about. For example, I knew the feature โ€œNeighborhoodโ€ would be important, as a famous rule of real estate is โ€œlocation, location, locationโ€, i.e. location is an extremely critical factor in pricing. Another example is that I knew that โ€œLotAreaโ€, or the size of the property,  would be important, as the square footage of a property has a direct impact on real estate price. I also did research, and learned the importance of certain features, like masonry veneer type, in determining real estate value. For features I wasnโ€™t sure about I created scatterplots or catplots to confirm I should use them.

I was concerned that perhaps the features โ€œOverallQualโ€ and โ€œOverallCondโ€, and likewise the features โ€œBsmtQualโ€ and โ€œBsmtCondโ€ would be highly correlated, so I created a scatterplots to check if this was the case. It was not the case, so I used all these features for modelling. Catplots were used to confirm that they were all useful in determining the sale price.

 

Data onFeature Engineering: Replacing Features & Creating New Features

I wanted to approach feature engineering and selection from the standpoint of someone with a real understanding of real estate. So I decided to reduce dimensionality and convert features into new ones that really have an effect on real estate price, based on what I know about real estate and based on research.

New features I created:

"PropOfBsmtFinishedโ€

  • โ€œPropOfBsmtFinishedโ€ i.e. proportion of the basement that is finished- I used the features โ€œBsmtUnfSFโ€ and โ€œTotalBsmtSFโ€ to create this new feature, and then did not use โ€œBsmtUnfSFโ€ for modelling. I figured that a feature that tells us what proportion of the basement is finished is much more useful in determining sale price than a feature of the unfinished square footage of the basement. My thinking was that if a home with a basement of size 900 square feet has 400 square feet of unfinished space, the unfinished square footage of the basement isnโ€™t as significant in affecting sale price as a basement of size 400 square feet with 400 square feet of unfinished space. In one house you have majority of the basement already finished, and in the other the entire basement isnโ€™t done. Therefore, it makes much more sense to replace the feature โ€œBsmtUnfSFโ€ with โ€œPropOfBsmtFinishedโ€. The formula I used to create โ€œPropOfBsmtFinishedโ€ =1-(โ€œBsmtUnfSFโ€/'TotalBsmtSF')

"NumFullBathโ€

  • โ€œNumFullBathโ€- I took the sum of โ€œBsmtFullBathโ€ and โ€œFullBathโ€ to create this feature and use it for the modelling instead of them. Each full bathroom adds a certain amount of real estate value so I figured it would make sense to have them together in one feature.

โ€œNumHalfBathโ€

  • โ€œNumHalfBathโ€- I took the sum of โ€œBsmtHalfBathโ€ and โ€œHalfBathโ€ to create this feature and use it for the modelling instead of them. Each half bathroom adds a certain amount of real estate value (different from full bathroom) so I figured it would make sense to have them together in one feature.

โ€œQuantAndQualFPโ€

  • โ€œQuantAndQualFPโ€ i.e. quantity and quality of fireplaces-  I combined โ€œFireplacesโ€, i.e. fireplace quantity, and โ€œFireplaceQuโ€, i.e. fireplace quality, into one feature. I did this because I thought having these features separate was redundant, as most houses have zero fireplaces and hence automatically no quality factor. In โ€œQuantAndQualFPโ€ there were some categories with extremely few observations, so I put them into categories that seemed to be the most similar to them after plotting a catplot versus the sale price.

 

โ€œTotalPorchDeckSFโ€

  • โ€œTotalPorchDeckSFโ€- I took the sum of all the porch/deck square footage, which is the sum of the features โ€œWoodDeckSFโ€, โ€œOpenPorchSFโ€, โ€œEnclosedPorchโ€, โ€œ3SsnPorchโ€, and โ€œScreenPorchโ€. I did this to reduce dimensionality and because it makes sense to have this as one feature in determining real estate value.

โ€œHasPoolโ€

  • โ€œHasPoolโ€- Instead of having the features โ€œPoolQCโ€, i.e. pool quality, and โ€œPoolAreaโ€, i.e size of pool in square feet, I made one feature, called โ€œHasPoolโ€, indicating whether or not the property has a pool. I did this because less than 1% of the data has a pool, so there werenโ€™t enough observations for the model to accurately predict how much the value goes up based on pool quality and pool size. Based on knowledge of real estate, I knew that having a pool significantly increases the value of a home, so I wanted to have one feature that indicates whether a home has a pool or not.

Adjusting Skewed Distributions for the Linear Models

Linear models work best when the features distributions are normally distributed. The distribution of sale price was right skewed, so I took the log and changed โ€œSalePriceโ€ to โ€œLogSalePriceโ€. I also adjusted other distributions. I took the square root of โ€œMasVnrAreaโ€, โ€œTotalBsmtSFโ€, and โ€œGarageAreaโ€; and I took the log of โ€œLotAreaโ€ and โ€œGrLivAreaโ€.

Removing Outliers

I removed two outliers based on โ€œGrLivAreaโ€ V. โ€œSalePriceโ€. I removed the two observations closest to the bottom right corner of the plot.

Dummifying Features for the Linear Models

For the linear modeling I dummified the categorical features. For the feature โ€œRoofStyleโ€, I dropped all of the dummified columns but one, that being โ€œRoofStyle_Hipโ€, because the only 2 categories with enough observations for valid analysis were Gable and Hip.

In the end I also dropped โ€œBsmtQual_NoBasementโ€, โ€œBsmtCond_NoBasementโ€, and โ€œBsmtExposure_NoBasementโ€. I did so because I observed that they had a significant impact on the model when I checked the statistics on the linear model, thereby negatively impacting the model since we already had the feature โ€œ'SqrtTotalBsmtSFโ€, i.e. the basement square footage, which for a value of zero is equivalent to saying no basement. So, I wanted to avoid multicollinearity, and removing these features did in fact improve the model.

Ordinal Encoding for the Non-linear Models

For the non linear models, I used ordinal encoding instead of dummification. This led to better model performance.

Data Model Results

  1. Tree-based: After performing a grid search for best parameters, Train Score: .952, Test Score: .781
  2. Random forest: After performing a grid search for best parameters, Train Score: .909, Test Score: .864
  3. Gradient boosting: After performing a grid search, Train Score: .961, Test Score: .908
  4. Support vector machine: Train Score: .938, Test Score: .879
  5. Non-penalized linear model: Train Score: .943, Test Score: .899
  6. Ridge linear regression model: After checking for optimal lambda, Train Score: .937, Test Score: .910
  7. Lasso linear regression model: After checking for optimal lambda, Train Score: .942, Test Score: .906

It turns out that the ridge regression model was the best model and gave the best score on Kaggle. The fact that a linear regression model was the best led me to believe that the way I approached feature engineering made sense. The best value for lambda was 4.

Findings From the Data

These were the features with the biggest impact on the model and their coefficients:

LogGrLivArea 0.294413
Neighborhood_StoneBr 0.104813
MSZoning_FV 0.099653
SaleType_New 0.099259
BsmtQual_TA -0.093233
Exterior1st_BrkComm -0.091236
Neighborhood_Crawfor 0.089791
Exterior1st_BrkFace 0.080073
Neighborhood_MeadowV -0.079241
MSSubClass_30 -0.072841
LogLotArea 0.072096
Neighborhood_NoRidge 0.069935
CentralAir_Y 0.069544
HouseStyle_2.5Fin 0.066885

Data Analysis

It turns out that the square footage of the above ground living area, the neighborhood, the zoning classification, the sale type, the basement quality, the exterior material, the building class/type of dwelling (including details such as age, presence of attic, how many stories, finished/unfinished, levels and level style), the square footage of the lot area, the presence of central air conditioning, and the house style (how many stories and whether the 2nd floor is finished) are key factors that effect real estate value.

Conclusion

Some of the key factors that significantly influence real estate value can't be changed by a home owner. However, some can, and it may be worth it for a home owner to take these factors into account and invest in their home.

There are two types of upgrades that are smart for a home owner to invest in:

  1. An upgrade that they want for themselves for personal benefit, and the upgrade is an investment that doesn't depreciate quickly.
  2. An upgrade that they don't necessarily want, but it is an investment that will end up increasing the value of the home by more than they spend on the upgrade. Although they don't care about the upgrade, it is a way to gain profit.

If one of the two above conditions apply, then based on the features that the model shows are most significant, it would be smartest for a home owner to invest in any of the following: Upgrading the exterior material, upgrading the quality of the basement, expanding the square footage of the home, finishing the 2nd floor if they have one, and installing central air conditioning if it is something the home lacks.

About Author

Leba Wilamowsky

View all posts by Leba Wilamowsky >

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