Allstate Claims Severity Solution
By: Satishkumar Moparthi
Tags: Python3, Machine Learning, Xgbregressor, Modeling, Lightgbm

Here I am highlighting my work on Allstate Claims Prediction, a Kaggle problem.

Source : Google Images

The Allstate Corporation is an American insurance company, headquartered in Northfield Township , Illinois, near Northbrook since 1967. Founded in 1931 as part of Sears, Roebuck and Co., it was spun off in 1993. The company also has personal lines insurance operations in Canada.

“Good Hands”

Allstate’s slogan “You’re in good hands” was created in the 1950s by Allstate Insurance Company’s sales executive, Davis W. Ellis. When you’ve been devastated by a serious car accident, your focus is on the things that matter the most: family, friends, and other loved ones. Pushing paper with your insurance agent is the last place you want your time or mental energy spent. This is why Allstate, a personal insurer in the United States, is continually seeking fresh ideas to improve their claims service for the over 16 million households they protect.

They are committed to create a truly immersive service, Allstate is currently developing automated methods of predicting the cost, and hence severity, of claims.

Here I am highlighting the stepwise approach of my work.

Understanding Business Problem Business Objective and Constraints Data Evaluation Metric EDA Data Preparation Modeling Future Work Reference

1. Understanding Business Problem:

Best Phrase about customers is Put yourself in their shoes. And every company wants their customers to not leave. A happy customer isn’t just someone who makes a purchase with you today. A truly happy customer is one who will be loyal to you and your business for a long time to come and customer loyalty and happiness have a tendency to spread. The most important thing is as the number of unhappy customers increases, the growth of the company decreases. So a company can address these things by using loss Prediction. Our task is to predict how severe the claim will or might be for a new household, predict future loss based on given features.

2. Business Objectives and Constraints:

There is no strict low latency requirement.

Minimize the loss

3. Data:

Allstate have provided anonymized data (changed feature names) and this dataset makes really hard to understand features. Dataset contains claim records of Allstate clients. There are two data sets available on the competition website on Kaggle.

train.csv — This file is containing 188318 number of rows and 132 features, id (unique id) and loss(target variable).

test.csv — This file is containing 125546 number of rows and 131 features, id (unique id) and features. You must predict the loss value for the ids in this file.

The anonymity of the data makes it difficult to get an intuitive feeling of what information given results or models are providing us with. It is, however, understandable that Allstate takes such a measure to protect anonymity and confidentiality. As the target variable is numeric and loss value we can pose this problem as a Regression problem. By doing this in my opinion will enhance overall customer service which will be beneficial for the company as well as the claimant plus help the insurance company.

4. Evaluation Metric:

The goal of this project is to predict the cost of insurance claims in order to help improve insurance claim severity analysis and provide better targeted assistance to customers. For predicting the cost , we need to know the amount, which is real number that can be claimed in insurance policy. So, we can’t use R-squared or Adjusted R-squared.

Metric to be used — Mean Absolute Error (MAE)

The mean absolute error measures the average magnitude of the errors on a set of forecasts, without considering the direction.

n — Number of data points, y(i)- Observed values and y^(i) — Predicted values

MAE is the average over the verification sample of the absolute values of the differences between forecast and the corresponding observation. The MAE is a linear score which means that the all the individual differences are weighted equally in the average.

5. EDA:

5. 1 Dataset overview:

Given data have only Cat and Con and no idea what exactly they are. As the features are anonymous, EDA became a very important stage for understanding more insights of the data.

Already explained about the dataset.

There are a total of 130 distinct features excluding target feature and id feature. These features contain categorical and numerical data types. Out of 130 features, 116 are categorical and 14 are numerical. We noticed that there are no missing values in the train dataset. This shows that Allstate provided highly user friendly prepossessed data.

5. 2 Missing values:

Let’s check for missing values.

As there are no missing values in train and test data we no need to do pre-processing.

5. 3 Plots:

Histogram of continuous features

There are many spikes in the continuous which shows that features are not distributed normally. We try transforming these features making their distribution more gaussian, but it might not improve the model’s performance

Box-Plot of continuous features

There are few outliers in cont7, cont9 and cont10 features. As stated above in this context, outliers are important to analysis, so we are not going to remove them.

Correlation matrix of continuous features

cont11 and cont12 give an almost linear pattern…one must be removed 2. cont1 and cont9 are highly correlated …either of them could be safely removed cont6 and cont10 show very good correlation too

We see a high correlation on above listed features. This may be a result of a data-based multicollinearity as two or more predictors are highly correlated. There are many problems it causes, so we should be very careful while implementing linear regression models on current dataset.

Calculating the skewness on continuous features

Continuous variable 2 and 3 are left skewed ( Cont3 not skewed much ~ 0) Cont9 ( 1.0 + ) variable is more skewed compared to other cont. variables Target variable is highly skewed. The Box-Cox transformation transforms our data so that it closely resembles a normal distribution. In many statistical techniques, we assume that the errors are normally distributed

Analyzing Target variable

There are several distinctive peaks in the loss values representing severe accidents [ high Claims ]. Such data distribution makes this feature very skewed and can result in suboptimal performance of the regressor. From Skewed results we see that Loss is right skewed [ 3.7 ] We can apply log transformation on loss variable and plot the graphs to visualize the updated loss ( log ).

From the above figure , we can confirm that after applying the log transform , now data seems to be normally distributed.

As we applied logarithmic function on target feature to convert it into normal distribution. We have to apply exponential function on test data while measuring / predicting the loss ( e**y )

Categorical Feature Analysis

As there are 132 features in categorical , please check out my GitHub to visualize the plots for categorical features. Here I am analyzing top 10 categorical features.

Top 10 important categorical features ( Random Forest )

Box-Plot

For Cat79,Cat57, Cat87,Cat81,Cat12,Cat89 and Cat7 , the data is spread around the median. For the Categorical feature Cat80 the median is equal to 75th percentile. More data falls below the median. For the Categorical feature Cat101 we can observer that the data falling above the median values. Cat106 is looking good compared to other features with minimum , max and IQR values. From the box-plot we can observe that most of the claims are limited to small values. We can observer this by plotting scatter plot. There are few high claims for Cat101 and Cat106 features.

Count-plots