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

Xu Huang, Jinsoo Kim, Jensen Hu, Xinyue Yuan and Shani Fisher
Posted on Sep 3, 2018

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

1. Introduction

Based on data, there are several factors involved with the sale price of a house. Some things that come to mind are size, number of bedrooms, year built, neighborhood, proximity to grocery store, etc.

In the Kaggle Competition: โ€œHouse Prices: Advanced Regression Techniquesโ€ created by Dr. Dean De Cock, our team explored a multitude of variables to further understand what influences the value of a house and how we can use these variables to predict the sales price given specific characteristics.

The goals for this project were:

  • Explore the data set and variable influences on sales price
  • Address data missingness, skewness
  • Feature engineer
  • Deploy machine learning methods

 

2. Data Preprocessing

2.1 Data Exploration

The first thing after getting this dataset is to explore the data. This dataset contains all kinds of data type: numeric, ordinal, categorical and binomial.

Using Data to Predict House Prices in Ames, Iowa

2.2 Data Cleaning

  • Using Data to Analyze Finding Outliers

    For finding outliers which decrease fitting performance of prediction model, We made assumptions that follows common sense. People usually consider Unit Price of houses. And they might listen to voice of the market, Overall Quality Ratings.

    Commonly, these two variables have a proportional relationship. And the Unit Price will follows normal distribution by each rating. Anyone can think this. And we will check our given data follow these assumptions through this plot.Using Data to Predict House Prices in Ames, IowaNow, we can see distribution shapes of normal distribution by each rating and found little bit strange shaped distribution, rating 10. What happens in rating 10?

  • Using Data to Analyze Handling Outliers

    We checked all of data at rating 10. As results, 13 outliers were found. And we removed 2 outliers which are leverages in 9 variables. So, we could improve fitting slopes and R-squared coefficients (0.69 โ†’ 0.77) each variable. Below, this table is about improved slope value changes.
    Using Data to Predict House Prices in Ames, Iowa
    And these plots describes examples of slope changes.
    Using Data to Predict House Prices in Ames, Iowa
    The R-squared values and betas are coefficients of slope from multi linear regression score. Actually, these value improvements are not directly related to result of this project. But, these will contribute to models in the prediction procedure.

  • Using Data to Analyze Transformation

    As one of the assumptions for linear regression, we checked normalities of all numerical variables. The test method was Dโ€™Agostinoโ€™s K-square test.
    Using Data to Predict House Prices in Ames, Iowa
    This variable doesnโ€™t follow normal distribution. So, we transformed these by using logarithm, reciprocal, square root and reciprocal square root transformation method.
    Using Data to Predict House Prices in Ames, Iowa
    We transformed 10 explanatory variables and corrected their skewness and kurtosis. And not only explanatory variables, also target variable (SalePrice) could be corrected with log transformation method.
    Using Data to Predict House Prices in Ames, Iowa
    This plot describes positive direction skewness. We tried all methods for correcting this.
    Using Data to Predict House Prices in Ames, Iowa
    Finally, we could optimize the correction through log-transformation.
    Using Data to Predict House Prices in Ames, Iowa
    We can check the difference between before and after transformation. Original data looked like quadratic distribution on the red line. But, now it became nearly linear. That means this data follows normal distribution. Of course, after we finish predict from this dataset, we will change transformed target value by using exponential function.

2.3 Using Data to Analyze Missing Imputation (1/2)

The entire data set (training + test) has 34 variables with missing data, 13,965 values out of 115,340 values (12%). Some of the variables, such as โ€˜PoolQCโ€™, โ€˜MscFeatureโ€™, โ€˜Alleyโ€™ and โ€˜Fenceโ€™, have more than 80% data missing. The imputation of those columns could be a huge challenge without any leads. The natural way is to find how the original data set says about those variables.

Using Data to Predict House Prices in Ames, Iowa

The data description has specific definitions for many of the โ€˜NAโ€™s in the data set, for example, โ€˜NAโ€™s in โ€˜Alleyโ€™ column simply indicates that there is no alley for the house, and โ€˜GarageAreaโ€™ would be โ€˜NAโ€™ too if there is no garage in the house. Therefore, by looking at the data description, 15 categorical and 10 numerical features can be imputed by either โ€˜Noneโ€™ or number 0, depending on the original data type of the feature.

Using Data to Predict House Prices in Ames, Iowa

After this round, we only have 34-25 = 9 columns left to be imputed. If we look at the numbers of the missing data among those features, 8 of them are only missing less than 4 values, which can be imputed by the most frequent values in their corresponding columns. Now, the only feature left here is โ€˜LotFrontageโ€™, the linear feet of street connected to property.

Since there are 486 (17%) data missing, a cautious way to handle it is to use kNN to help determine the values, with the consideration of all other features, including โ€˜Neighborhoodโ€™ and โ€˜LandContourโ€™ that may have bigger influence on the street around the house. However, in order to use kNN, we have to wait until all other categorical features to be properly converted (labeled) with numbers.

2.4 Using Data to Analyze Label Encoding

There are 79 features (36 numerical + 43 categorical). We examined each of them and divided them into 4 cases: A, B, C and D to handle them differently. Case A indicate 33 numeric features that do not need any further transformation. They are mainly area in square feet, or quality levels that are already in ordinal numbers.

Using Data to Predict House Prices in Ames, Iowa

Case B, however, are 3 numerical features that require closer look. By definition, โ€˜MSSubClassโ€™ is using integer numbers to indicate certain house types. Therefore, they are actually categorical values. We converted this feature to categorical -> numerical by sorting out their corresponding average โ€˜SalePriceโ€™. โ€˜SalePriceโ€™ does not have monotonic dependence on โ€˜MoSoldโ€™ or โ€˜YrSoldโ€™ either. So we also converted them in a similar way as โ€˜MSSubClassโ€™.

Using Data to Predict House Prices in Ames, Iowa

Case C consists 25 categorical features that are evaluating qualities or conditions. They can be intuitively labeled by ordinal integer numbers. Some of them, such as LandSlopeโ€™, โ€˜LandContourโ€™ and โ€˜Functionalโ€™, are also showing specific trends regarding certain house conditions. So they were also labeled based on their direct meanings.

Using Data to Predict House Prices in Ames, Iowa

Case D includes the last 18 features with categorical values that are not showing obvious dependence with โ€˜SalePriceโ€™ by the first look. For example, it is hard to tell how the โ€˜RoofMat1โ€™, โ€˜GarageTypeโ€™, โ€˜SaleTypeโ€™ or โ€˜Neighborhoodโ€™ would influence the house price. Instead of โ€˜one-hot-labelingโ€™ or ranking them based on value frequency, we again use their corresponding average โ€˜SalePriceโ€™ to sort and give them integer labels as we did to Case B.

Using Data to Predict House Prices in Ames, Iowa

2.5 Using Data to Analyze Missing Imputation (2/2)

With all the other 78 columns filled and properly converted to numerical values, it is time to revisit the last column with missing data. We chose to use Manhattan distance to impute โ€˜LotFrontageโ€™ to reflect more subtle details from other data points and to reduce the influence from larger distance dominating the imputation results. k-Neighbor = 5 was determined by the R^2 resulted by a series tests of k numbers.

Using Data to Predict House Prices in Ames, Iowa

 

3. Using Data to Analyze Modeling

3.1 Using Data to Analyze Base Models

Three linear models were tested and used to predicted on the training data. While Ridge Regression tend to keep all the 79 features, Lasso Regression dropped 24 features as unimportant. After the grid search Elastic Net Regression consisted 91% of Lasso. In all cases the โ€˜OverallQualโ€™, โ€˜OverallCondโ€™ and โ€˜GrLivAreaโ€™ are the three features that show most import positive influences on the โ€˜SalePriceโ€™.

Using Data to Predict House Prices in Ames, Iowa

Besides linear models, two tree models, Gradient Boosting and Random Forest, as well as a non-linear model, Kernel Ridge Regression were also tested and used for house price prediction. The corresponding training error and Kaggle Public Board error are shown below.

Using Data to Predict House Prices in Ames, Iowa

The training and PB errors show that overall our Gradient Boosting and Kernel Ridge models are making the best prediction, linear models show slightly larger errors, and that the Random Forest model produces largest errors. Therefore we chose Gradient Boosting (GBoost), Elastic Net (ENet) and Kernel Ridge (KRR) Regression for further model stacking.

Using Data to Predict House Prices in Ames, Iowa

Before running into model stacking, we examined the actual comparison between the predicted and true โ€˜SalePriceโ€™ values along the y = x line for our three best models. ENet and KRR show similar data distribution features despite the fact that ENet has bigger errors at high price region, mainly because they are both using l2-squared error in the loss function. One of the main sources of our linear models is rooted in the multicollinearity: We didnโ€™t combine strongly correlated living/basement area features.

Comparing with the other two, GBoost did better overall predictions, but it still made several predictions that are far deviated from the y = x line. Therefore, further model stacking is needed to help adjust the differences between models to give more accurate results. A simple averaging between the predicted โ€˜SalePriceโ€™ among three models has already reduce the training and PB error significantly.

3.2 Using Data to Analyze Model Stacking & Ensembling

Our stacking approach followed simple โ€œgreedy mannerโ€. Since we only have three starting models, there are only three choices for the meta-model when picking two as bases. Our results shows that the meta-model of ENet trained by stacking GBoost & KRR gave the lowest errors, which are lower than the simple averaging results.

Using Data to Predict House Prices in Ames, Iowa

For the model ensembling, we again apply the greedy forward approach: picking up the best model, linear Lasso Regression among other candidates. With a simple ensembling formula of 3 quarters of meta-model + 1 quarter of Lasso, our final RMSLE PB error was further lowered down to 0.11718, among the top 600 results.

4. Future Works

Since the main source of our linear models came from multicollinearity, our future improvement in the data pre-processing part will be including:

  • Combining different group features, especially those involving aspects with living / basement / garage areas
  • The skewness transformation can be performed after feature engineering;
    Different skewness transformation methods for both features and target columns can be used besides Box-Cox and Log.

Meanwhile, for the modeling part:

  • More diverse or advanced/efficient machine learning models can be included, such as XGB, LightGBM, PCAโ€ฆ
  • Based more models and improved results, more stacking & ensembling combinations can be tested to further lower down the errors.

 

References & Useful Links

For more information, welcome to visit our group GitHub to find more details. We also thank Kaggle Kernel authors for useful EDA and modeling insights for the dataset.

About Authors

Xu Huang

Xu Huang got PhD in Computational Chemistry from University of Iowa and B.S. in Chemistry from Peking University. Her study includes developing & testing the computational code to improve the accuracy for the modeling of battery material &...
View all posts by Xu Huang >

Jinsoo Kim

Jinsoo Kim has an engineer career in steel manufacturing. While working for POSCO, he has participated in the Smart Factory project. He holds a bachelor's degree in mechanical engineering from Inha University, South Korea.
View all posts by Jinsoo Kim >

Jensen Hu

View all posts by Jensen Hu >

Xinyue Yuan

View all posts by Xinyue Yuan >

Shani Fisher

View all posts by Shani Fisher >

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