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 > Python > Using Data to Predict housing prices in Russia

Using Data to Predict housing prices in Russia

Fouad Yared, Jason Chiu, Fu-Yuan Cheng and Christopher Behrens
Posted on Jun 27, 2017
The skills the author demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

Predicting housing prices in Russia

Sberbank, Russia's largest bank, published housing data on Kaggle in early 2017. The bank's goal was to better understand which aspects (such as the size of one's home or proximity to a train station) affected individual housing prices.

Our team, consisxUsing Data to Predict housing prices in Russiating of Chris Behrens, Fu-Yuan Cheng, Jason Chiu, and Fouad Yared, cleaned the data sets, performed exploratory data analysis, conducted linear regression, lasso regression, random forest, and xgboost in order to address the task at hand.

The team used R for data cleaning, exploratory data analysis, principal components analysis, linear regression, and lasso regression. Python was used for k-means cluster analysis, random forest and xgboost.

Before beginning our analysis and model creation, we wanted to understand the variables. Sberbank's housing data was split into two groups: a training set to train our machine learning models and a test set which we would predict.

Cleaning the data set

Our data cleaning process consisted of two steps: 1) finding which features contained extreme or erroneous values and 2) identifying and filling in missing data.

Since data cleaning was handled in R, the summary() and table() methods were used to find features that required further inspection and possible action. Features with extreme or erroneous values were nullified.

In assessing missingness, the team found 51 of the 292 variables in the training set had missing values. Variables with missing values that were highly correlated with others were removed from our analysis. A variable that was missing more than 40% of its values (the count of hospital beds) was removed from our analysis.

Figure 0: The different types of variables found in Sberbank's Russian housing data set. The middle variable, property price, is the variable we are predicting. The other variables are used in creating our prediction.

Missing data was most often filled in by calculating the median value of a given feature based on its sub-area. K-Nearest Neighbor (KNN) was also used to compute missingness. It varied from the group median since it considered many variables when filling in missing data.

By inspecting the data set, our team found missingness was related to time. For instance, if we look at the eight building characteristics (including the year a home was built and the total square meters of a home), we see that 6 of these 8 variables were missing 100% of their values from Q3 2011 to Q1 2013. (Dates for the training data set ranged from Q3 2011 to Q2 2015.)

Using Data to Predict housing prices in Russia

Figure 1: Missingness by quarter

Each panel represents one of eight building characteristics and the percentage of missing values for each quarter of the year, starting with Q3 2011 and ending with Q2 2015. In the top left we see build_year was missing 100% of its values from Q3 2011 to Q1 2013. The same pattern of missingness is shared by five other variables: kitch_sq, material, max_floor, num_room, and state.

Also, missingness was often shared among variables. When one variable was missing a set number of values, a related variable would often have the same number of missing values as well.

Understanding our data through exploratory data analysis

In order to find which variables should be included in our models, our team looked at the one hundred variables that correlated highest with the price of housing. If there were a group of variables that were highly correlated with one another, only one variable would be retained for our models.

The three variables that correlated highest with a home's price were the total area in square meters, the living area in square meters, and the number of rooms. An underlying issue is that each of these three variables does not follow a normal distribution. In a linear model, these variables will need to be transformed in order to satisfy the normality assumption of multiple linear regression and lasso regression.

Figure 2:

Exploratory data analysis showing the correlation of an entire unit's square meters compared to its price (top-left), the number of rooms by price (top-right), the livable square meters of a unit by its price (bottom-left), and the size of the kitchen compared to the price of a unit (bottom-right). On the right hand side we have a correlation matrix showing how related each of the building characteristics are to one another.

Using Data to Predict housing prices in Russia

Other building, location, lifestyle (the number of cafes, sport facilities, and/or shopping malls), education, and cultural characteristics did not have as strong of individual correlations with price.

Figure 3: A listing of the 23 variables most highly correlated with a house's price. They are ranked in absolute value.

While correlations are useful in understanding the relationship of two variables, they do not take into account the effects of other variables, which will be considered through our multivariate models.

After selecting the most correlated and most unique features, we built multiple linear regression and lasso regression models to 1) find out the relationship of the remaining variables and a house's price and 2) to further reduce the number of variables used in interpreting our model.

Building our linear machine learning models

Figure 4: Multiple Linear Regression Model Building Process

The team prioritized interpretability and story-driven model building, and therefore, adopted a bottom-up approach in feature selection and engineering (Figure 4).

From the very beginning, we classified features into subgroups, and unsupervised learning techniques were used to engineer additional features.

For example, distance to public transportation included walking and driving distances to metro stops, train stations, bus terminals, and railroad stations. Many transportation features were highly correlated, and a principal component analysis (PCA) was used to remove information redundancy and to reduce the number of dimensions.

Findings

We also used k-means clustering to examine the underlying patterns of environmental conditions in neighborhoods. We found that overall neighborhoods could be classified into these subgroups:

  • safe neighborhoods with no exposure to environmental toxins,
  • neighborhoods that are exposed to nuclear reactor and/or radioactive waste, and 3) toxic industrial neighborhoods that are exposed to multiple sources of toxins including a chemical industry, radioactive waste, and thermal power plants (Table 1).

The team examined one subgroup of features at a time, such as education and life style, and new features were then included in the model building.

Due to the high number of features, a combination of forward Multiple Linear Regression and Lasso Regression were used to identify the most important variables. Model fit was assessed using training data R2 (Coefficient of Determination), AIC (Akaike Information Criterion), and root mean squared logarithmic error (RMSLE), and Kaggle RMSLE (testing data).

We chose the forward selection method in multiple regression to retain only the variables that had a significant contribution to the price. Lasso regression also selects a subset of the variables we originally pass, as the other variables shrink to zero if they are not significant predictors of price.

Evaluating our linear machine learning models

While the training data R2, AIC, and RMSLE continued to improve, we soon encountered the challenge of overfitting as our training error was much better than our test error.

The basic assumptions of MLR were examined and multiple assumptions were violated with the current model, such as residual normality (Figure 5). Most importantly, non-linear patterns were observed in residuals vs. predicted log prices.

Figure 5. Residual Q-Q plot

We further investigated the lines and found that many listings in the data sets with different characteristics were sold at the same price. For example, around 800 properties were sold at 2 million Rubles. With MLR, we noticed there was a linear relationship between the total area (in square meters) of a property and its price, yet many properties with different characteristics were sold at the same price. This revealed a violation in linearity.

After careful consideration, the team decided that MLR will not fit the current data. Instead, non-linear tree-based models, namely random forest and xgboost, were used to better understand the relationship between our predictors and our target variable.

Figure 6:

Our error terms should be fairly consistent over time, yet we have multiple lines that note the linear models we've used aren't enough for accurately predicting housing prices.

Random Forest

We chose to use a random forest model for two reasons. First, a random forest would look at non-linear relationships between our predictors and target variable. Second, it would help identify the most important features through its feature importance output.

Model Building

We started with a random forest model with the building characteristics, such as total square meters, the build year, and whether it was owner-occupied or investor-owned. Additional features were added to enhance our model fit.

We used 10-fold cross validation and grid search to find the best hyper-parameters, which included the number of estimators and the max features to be selected in each tree. We also used one-hot encoding in Python to convert our sub-areas and administrative regions into dummy variables, which we tested in the model.

Our models were evaluated with the root mean squared logarithmic error (RMSLE) and Kaggle RMSLE (testing data).

Model Evaluation:

We determined the best hyper-parameters for our model that included sub-areas and administrative regions were 400 trees with 20 max features and 400 trees with 12 features. Random forest didn't provide the overfitting problems like linear or lasso regression. Most importantly, we decreased the RMSLE (error) significantly.

We further investigated feature importance. The total square meters of a unit and the number of rooms turned out to be important features in our random forest model (which included sub-areas and administrative regions) and in our linear models.Figures 7 and 8 show the most important variables for our sub-area random forest model and for our administrative region random forest model, respectively.

Interestingly, although administrative regions had a low feature importance, the RMSLE decreased when we took regions into consideration.

Figure 7. Feature importance by sub-area

Figure 8. Feature importance by administrative area

About Authors

Fouad Yared

Dedicated to public service, Fouad Yared has four years experience working in the non-profit world: he advocated for tenants rights at Cleveland Tenants Organization and instructed classes on basic literacy and GED preparation at the Cuyahoga County Jail....
View all posts by Fouad Yared >

Jason Chiu

Jason is a public health researcher and healthcare quality professional. He is passionate about using data to improve social enterprises. Jason is also an avid music aficionado and an amateur composer. He enjoys a wide range of music,...
View all posts by Jason Chiu >

Fu-Yuan Cheng

Fu-Yuan comes from a background in mathematical science and is pursuing a master's degree in applied analytics from Columbia University. While applying time series models to financial data, he discovered he had a passion for machine learning and...
View all posts by Fu-Yuan Cheng >

Christopher Behrens

Chris Behrens is a focused and hardworking data scientist. He graduated from Georgetown in May 2016 with a degree in Economics. After college, he worked as a survey analyst on the Hillary For America campaign. He is currently...
View all posts by Christopher Behrens >

Related Articles

Capstone
Catching Fraud in the Healthcare System
Capstone
The Convenience Factor: How Grocery Stores Impact Property Values
Capstone
Acquisition Due Dilligence Automation for Smaller Firms
Machine Learning
Pandemic Effects on the Ames Housing Market and Lifestyle
Machine Learning
The Ames Data Set: Sales Price Tackled With Diverse Models

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