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 > Kaggle competition: Liberty Mutual Group Property Inspection

Kaggle competition: Liberty Mutual Group Property Inspection

Xavier
Posted on Aug 19, 2015
The skills we demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

Machine Learning with Liberty Mutual Group Property Inspection Prediction Kaggle Data

– Authors: Claire Tu, Sumanth Reddy, Teresa Venezia, Xavier Capdepon, Zeyu Zhang.

– Claire, Sumonth, Teresa, Xavier and Zeyu were a student of the Data Science Bootcamp#2 (B002) – Data Science, Data Mining and Machine Learning – from June 1st to August 24th 2015. Teachers: Andrew, Bryan, Jason, Sam and Vivian.

– The post is based on their Kaggle Competition project final submission.

houses

Project:

Liberty Mutual Group Kaggle was a team project embarked on by Claire Tu, Sumanth Reddy, Teresa Venezia, Xavier Capdepon, and Zeyu Zhang.  The challenge was to build a model to predict the “hazard score” using a dataset of property information to “enable Liberty Mutual to more accurately identify high risk homes that require additional examination to confirm their insurability.”  Here is the link to the Kaggle competition website: https://www.kaggle.com/c/liberty-mutual-group-property-inspection-prediction

Exploring the Data

We first performed exploratory data analysis (EDA) to gain an understanding of the data, visualize any pattern or trends, and make decisions about features to use as inputs in the model.  The training data contained the “Hazard” response variable along with 32 predictor variables. The Hazard variable appeared as a numerical, discrete data type, although Liberty Mutual indicated that you “can think of the hazard score as a continuous number that represents the condition of the property as determined by the inspection.”

The predictor variables appeared to be either numerical, discrete data types or categorical data types.  This was difficult to discern because Liberty Mutual anonymized these predictor variables, preventing us from intuitively grouping these variables into categories (such as property or safety conditions, geography, and weather).  Not knowing the nature of these variable presented challenges that became readily apparent at this early stage.

For example, it was not clear if the 15 predictor variables that appeared as numeric might instead represent characteristics of the property.  Additionally, the 17 categorical data types were broken down into two categories: 12 categorical data types using single letters with no clear indication of ranking or importance, and 5 categorical Yes/No data types.  Furthermore, none of the predictor variables displayed strong correlations with the target Hazard, with only one showing a correlation greater than 0.1.

corr matrix

figure 1: Correlation Matrix Visualization of numerical variables

Closer Look at the Hazard Scores

The histogram of Hazard shows the values ranging from 1 through 70, with more than a third of the training data having a value of 1.histo of hazard rate

figure 2: Histogram of the Hazard score

With this in mind, we considered using a one-vs-all approach (i.e., Hazard scores of 1 vs. all other scores).  But our early exploration of this approach resulted in various challenges.  For example, when using a K-Nearest Neighbors method in Python and R our computers crashed. That happened because the high-dimensionality of the data demanded an extremely expensive computation.

Other methods, such as logistic regression, were computed but presented different challenges with the multi-level categorical variables. We considered transforming these categorical variable. However, without knowing the nature of these variables, we would have introduced the possibility of fabricating a structure in the variance that did not initially exist.  Finally, we tried logistic regression using only the numerical variables. As that model was not a good fit, we decided not to pursue the one vs. all idea.

Feature Selection

We also focused on reducing the dimensionality of the data through the Feature Selection.  First we examined the variance of each predictor variable, hoping to remove any variables with distinguishably low variance. However, most of the variables displayed similar variances.

features var for num columns

figure 3:  Low variance features selection graph for the numerical variables

We enjoyed some success when implementing the Random Forest method, which attempts to weight the importance of each predictor.  With this method, 4 predictor variables displayed limited or negative importance relative to the rest, and we considered removing those features.

rplot

figure 4:  Random Forest features selection graph far all variables

Our findings were similar when running univariate feature selection with the X2 test and F test for the numerical variables.

univariate features selection

figure 5:  Univariate features selection graph with X2 test for the numerical variables

univariate features selection F

figure 6:  Univariate features selection graph with F test for the numerical variables

Exploring Certain Models

Support Vector Machine (SVM):

We considered building a classifier using a Support Vector Machine method.  A SVM model represents data points from a training data set in a multi-dimensional space, mapped so that the data points of different categories are divided by a clear gap that is as wide as possible. The SVM builds a hyperplane or set of hyperplanes in a high or infinite-dimensional space, which can be used for classification.

When used on the test data set, the test data points are mapped into that same space and predicted to belong to a category based on which side of the gap they fall on.  Given the numerous categorical data, the model was relatively slow to process.  The SVM method provided categorical outputs which were not the most appropriate model for this exercise as a lot of information is lost by using the features in this categorical model.

IAs the description of the competition mentioned that the hazard score shall be seen as a continuous variable, we decided not to pursue this approach after seeing the first few results in the 0.3188, .

Gradient boosting machine (GBM):

In gradient boosting machines, the learning procedure fits new models to provide a more accurate estimate of the response variable. The principle idea behind this algorithm is to construct the new base-learners to be maximally correlated with the negative gradient of the loss function associated with the whole ensemble. It is particularly interesting in this exercise as the nature of the features is unknown.

We achieved a score of 0.368800 after running a grid of parameters for several hours.  Using this method, we spent considerable time “tuning” or tweaking the parameter values trying to generate a better fit, which took up to 3 hours to run depending on the parameter combinations.  We also observed that the running time for GBM in R was considerably reduced by parallelizing the “caret” package using the “doParallel” package on 7 CPUs where the “caret” package is launching the GBM R package.

Model Selection: xgboost and Random Forest Ensemble

Even after removing features that we found to be “less important”, we were still left with up to 30 predictor variables that showed no clear linear relationship with the Hazard target variable.

stripplot 5 top features

figure 7: “stripplot” graphs of the 5 top features selected by random forest

Random Forest:

Due to this fact, as well as our results with other models, we decided to use the Random Forest Regressor model in scikit-learn.  We ran two for loops to tune the two most important parameters in the random forest model: the n_estimators, which determines the number of trees in the forest, and also the max_depth, which determines the complexity or maximum depth of each tree.  Our Random Forest Regressor model gave us a normalized gini score of 0.36 on the public leader board, which ranked in the top 40 percent.  It was a good result, though we were still not satisfied.

Xgboost:

When searching the Kaggle forum, we found that most people on the leaderboard were using xgboost (extreme gradient boosting), which is a newly developed machine learning model.  When using random forest, we are trying to optimize the predictors; however, xgboost optimizes the whole tree instead of predictors.

We trained two xgboost models, one with all 32 features, and one excluding the least important four features.  By taking the sum of the two different weighted models, we reduced the probability of overfitting using the ensemble method.  The final xgboost model led us to the top 10 percent of the leaderboard.

Ensembling RandomForest and xgboost:

The idea of the ensemble method used in xgboost inspired us to ensemble the xgboost model and the Random Forest model.  We were encouraged to consider combining a model with a lower accuracy and higher accuracy by the MLWave blog post on ensembling approaches for Kaggle Competitions ( http://mlwave.com/kaggle-ensembling-guide/ ).

In that post, the author provides a detailed discussion about why ensembling a lower accuracy model increases the final outcome, pointing to several Kaggle competitions as examples. Following the guidance of the blog post, we are ranking 139/2109 right now (top 7%).

Comparison of Model Scores

Below is a table that illustrates the results and ranks of our models and the current Kaggle leaderboard. We remain committed to continuing to improve our model.

Model Score Rank
Best Competitor 0.395812 1
Xgboost (ensemble) 0.391169 139
Random Forest 0.373147 1086
GBM 0.3688 1160
SVM 0.3188 1740

About Author

Xavier

View all posts by Xavier >

Related Articles

Data Analysis
Injury Analysis of Soccer Players with Python
Machine Learning
Ames House Prices Predictions
Python
US Honey Production Analysis With Python (1998-2012)
Machine Learning
The Ames Data Set: Sales Price Tackled With Diverse Models
Python
EDA and machine learning Ames housing price prediction project

Leave a Comment

Cancel reply

You must be logged in to post a comment.

el blog del narco 2016 October 15, 2017
So now it appears full circle back to the individual who may have taken on the role in the blogging site administrator. However, whenever a blogger does enjoy what he writes about, he'll probably adhere to it for a time. A blog writing service knows how to spark the eye to your products and services, that may drive more visitors and bring about higher revenues for your business.
xavier August 22, 2015
we used python: import seaborn as sns sns.corrplot(libMut_train)
Harvey August 21, 2015
What did you use to create the correlation matrix?

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