Dear Readers, This is my very first article on Medium. This is about an auto insurance fraud prediction. Fraud predictions are usually an Imbalanced dataset with more legit claims than fraudulent Claims.
尊敬的读者,这是我关于Medium的第一篇文章。 这是关于汽车保险欺诈预测的。 欺诈预测通常是不合法的数据集,其合法性主张要比欺诈性主张多。
Problem Statement:
问题陈述:
These days lot of insurance companies , deal with fraudulent claims. The frauds can be at different stages , either at the stage of filling the proposal or at the time of claims like staging an accident or claiming pre-existing Damages. Frauds are committed to achieving personal gains. The data set I worked on has is called an imbalanced dataset with legit claims being far come as compared to fraudulent Claims. According to the FBI, non-health insurance fraud costs an estimated $40 billion per year, which increases the premiums for the average U.S. family between $400 and $700 annually
这些天很多保险公司,处理欺诈性索赔。 欺诈可以处于不同阶段,可以在填写提案的阶段,也可以在索赔时(例如上演事故或索赔预先存在的损害赔偿)。 欺诈致力于实现个人利益。 我处理的数据集称为不平衡数据集,与欺诈性索赔相比,合法索赔远远没有达到。 根据FBI的数据,非健康保险欺诈每年估计造成400亿美元的损失,这使美国普通家庭每年的保费收入增加了400到700美元
About the Dataset:
关于数据集:
The dataset has 1000 observations with 39 features. The dataset contains information about fraudulent claims from 01-Jan-2015 to 01-March-2015 in the state of Ohio,Indiana,Illinois. The data given does not mention the insurance company. So we are not aware that whether it is from an single insurance or multiple insurance companies. The obvious drawback about this dataset is that it has only 1000 observations.
数据集具有1000个具有39个特征的观测值。 数据集包含有关伊利诺伊州印第安纳州俄亥俄州从2015年1月1日至2015年3月1日的欺诈性索赔的信息。 给出的数据没有提及保险公司。 因此,我们不知道它来自单个保险公司还是多个保险公司。 此数据集的明显缺点是它只有1000个观测值。
EDA(Exploratory Data Analysis)
EDA(探索性数据分析)
The given Dataset has 1000 observations and 39 features,with the column fraud reported being the dependent variable(the variable that we wish to predict). The dependent Variable has 753 non-fraudulent cases and 247 fraudulent cases.
给定的数据集具有1000个观测值和39个特征,其中报告的列欺诈是因变量(我们希望预测的变量)。 因变量有753个非欺诈案件和247个欺诈案件。
No of Fradulent vs Non Fraudulent Cases. 欺诈案件与非欺诈案件的数量。Correlations among variables
变量之间的相关性
There was no significant correlation among variables except between months as customer and age(0.92) .The other being Total claims,injury claims,property claims and vehicle claim.Since Total claim is equal to the sum of Injury claim,property claim and vehicle claim.So I had to drop injury claim,property claim and vehicle claim.
变量之间没有显着的相关性,除了客户和年龄之间的月份(0.92)。另一个是索赔总额,伤害索赔,财产索赔和车辆索赔。因为索赔总额等于伤害索赔,财产索赔和车辆索赔的总和。因此,我不得不放弃伤害索赔,财产索赔和车辆索赔。
Correlation Matrix 相关矩阵To see how each variable affected the independent variable,I did an cross Tabulation between dependent variable and the independent variables. Post that I ran a chi square test to check whether they were dependent or not. Chi square is a non parametric test to check whether two variables are independent or independent.Some of the most common observations that were made post EDA were
为了了解每个变量如何影响自变量,我在因变量和自变量之间进行了交叉制表。 我进行了卡方检验后检查他们是否受养。 卡方检验是一种非参数检验,用于检查两个变量是独立的还是独立的.EDA后得出的一些最常见的观察结果是
The no of fraud cases was highest in state of South Carolina followed by new York.南卡罗来纳州的欺诈案件数量最高,其次是纽约。There was a significant relationship between hobbies and fraud reported. People who hobbies are chess and cross fit are more likely to commit fraud. 爱好和所报告的欺诈之间存在显着的关系。 爱好是国际象棋和运动量来找到的人更容易犯欺诈。 Fraudulent vs Non Fraudulent Cases for each type of Hobbies. 每种爱好的欺诈案件与非欺诈案件。3.There was significant relationship between the authorities contacted and fraudulent cases.Except in six cases ,all the fraudulent cases had contacted the authority (each of them were almost equal to 25%).
3.接触的当局与欺诈案件之间存在着显着的关系。除六起案件外,所有欺诈案件均已与当局接触(每宗案件几乎占25%)。
Authorities contacted for each of the fraudulent cases. 每个欺诈案件都与当局联系。4. The average claim amount of fraudulent claims were 10000$ more than non fraudulent claims.
4.欺诈性索赔的平均索赔额比非欺诈性索赔多10000 $。
5. 90% of cases were fraudulent if it was multi vehicle or single vehicle collision.
5.如果是多车碰撞或单车碰撞,则有90%的案件是欺诈的。
Incident_type vs fraudlent Cases Incident_type与欺诈案件6. If the collision was rear (42%) of the cases were fraudulent, followed by 27% for front and side collision.
6.如果碰撞是后方的(42%)是欺诈案件,其次是正面和侧面碰撞的27%。
Collision Type vs Fraudulent Cases. 冲突类型与欺诈案件。7.In the cases where fraud was reported, 71% cases had property damage associated with them.
7.在举报欺诈案件中,有71%的案件与财产损失有关。
There were missing values in the dataset. There were missing Values in the Columns Collision type(178),property damage(360),police report available(343). Dropping them will not be a feasible option because there are few observations in the data. Had there been lots of observations,we could have gone ahead and dropped them. In this case since the missing values are categorical in Nature, we can replace with most frequent or mode value.But there is a certain risk attached to it ,that it will have biasness attached to it. So now I used a different concept called MICE Imputation(You can read about it here-https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3074241/).
数据集中缺少值。 列冲突类型(178),财产损失(360),可用的警察报告(343)中缺少值。 删除它们将不是可行的选择,因为数据中几乎没有观察到。 如果有很多观察,我们可以继续进行下去,然后将其删除。 在这种情况下,由于缺失的值在自然界中是分类的,因此我们可以用最频繁的值或众数值来代替。但是存在一定的风险,它会带有偏见。 因此,现在我使用了一个不同的概念,称为MICE插补(您可以在此处阅读有关内容-https : //www.ncbi.nlm.nih.gov/pmc/articles/PMC3074241/)。
MICE(Multivariate imputation by chained equations). As the name suggests in place of replacing the missing variables using Univariate techniques, you use multivariate techniques.There are Actually 3 kinds of missing values. Missing at random,missing completely at random and Missing not at random(You can read About it Here-https://www.displayr.com/different-types-of-missing-data/). In our case the missing values was missing at random since it was related to the dependent Variable. In python, MICE equivalent is iterative imputer. Here I used Random Forest and linear regression to impute missing Values. But remember that before you use iterative imputer, Convert categorical Data into numerical Date and MICE works much better with R. So once I imputed the missing values and cross checked with earlier mode based imputation, I found out that that results were same.SO I was convinced that my result was accurate.
MICE(通过链式方程进行的多元插补)。 顾名思义,您可以使用多元技术来代替使用Univariate技术替换丢失的变量,实际上有3种丢失值。 随机丢失,完全随机丢失,而不是随机丢失(您可以在此处阅读关于它-https : //www.displayr.com/different-types-of-missing-data/)。 在我们的例子中,缺失值是随机丢失的,因为它与因变量有关。 在python中,MICE等效项是迭代迭代器。 在这里,我使用随机森林和线性回归来估算缺失值。 但是请记住,在使用迭代运算符之前,将分类数据转换为数字日期并且MICE在R上效果更好。因此,一旦我估算出缺失值并与基于早期模式的估算进行交叉检查,我发现结果是相同的。确信我的结果是准确的。
Model Building
建筑模型
During The model Building Stage,I used 5 algorithms to build my classification model. Those 5 models were
在模型构建阶段,我使用了5种算法来构建分类模型。 那五个模型是
XGBoostXGBoostLogistic Regression 逻辑回归 KnnnnRandom Forest 随机森林 Ada Boost.艾达助推器。Metrics Used:F1 score, Recall, AUC SCORE, Precision, Accuracy.
使用的度量标准:F1得分,召回率,AUC得分,准确性,准确性。
Since my data set was imbalanced .My most accurate metric will be(F1-score,Recall and AUC score).F1 score is the harmonic mean of recall and precision .Recall is out of all the fraudlent cases ,how many did my model predict correctly.AUC(Area Under Curve)-It tells me how much my model is capable of differentiating between the two classes.I used Pycaret Library,to generate my output. The advantage of Pycaret is we don't need to write a function to get the desired output.You just need to pre process your data and supply your dataframe and your target variable along with training and test percantage. SO this what the output I got.
由于我的数据集不平衡。我最准确的指标是(F1-得分,召回率和AUC得分)。F1得分是召回率和精确度的调和平均值。召回不属于所有欺诈案件,我的模型预测了多少正确。AUC(曲线下的面积)-它告诉我我的模型能够区分两个类。我使用了Pycaret库来生成我的输出。 Pycaret的优点是我们不需要编写函数即可获取所需的输出。您只需要预处理数据并提供数据框和目标变量以及训练和测试性能即可。 所以这是我得到的输出。
The best model which I got was XG boost with recall of 61.99 meaning out of every 10 fraudulent cases 6 were correctly identified an F1 score of 63.55.the AUC score was 85.51% indicating that 86% of the times my model was capable in separating the two classes.
我得到的最好的模型是XG提升,召回率为61.99,这意味着每10个欺诈案件中有6个被正确识别为F1得分63.55.AUC得分为85.51%,表明我的模型能够分离出86%的模型两课。
The test set also got a accuracy of 82% and an AUC of 87.71,Recall of 64.52,Precision of 63.49,F1=64.Since ,my metrics of test set and training set were similar which indicated there was no overfitting and both have got high accuracy and were also similar on other metrics,indicating no/less biasness
该测试集的准确度也达到82%,AUC为87.71,召回率为64.52,精度为63.49,F1 = 64。由于我的测试集和训练集的指标相似,表明没有过度拟合并且都得到了精度高,在其他指标上也很相似,表示无偏小
PS:The results might change depending on size of the dataset and the imbalance in case of dependent variable(Github Link:https://github.com/neelcoder/-symmetrical-robot).
PS:结果可能会根据数据集的大小和因变量的不平衡而变化(Github链接: https : //github.com/neelcoder/-symmetrical-robot )。
If you have any Doubts.Please do reach out.
如果您有任何疑问,请与我们联系。
LinkedIn Profile(https://www.linkedin.com/in/neel-roy-55743a12a/)
领英个人资料( https://www.linkedin.com/in/neel-roy-55743a12a/ )
翻译自: https://medium.com/@neel.roy/auto-insurance-fraud-prediction-f3e7cfba8f1d
相关资源:Fraud Detection Using GraphDB 基于图数据库的反欺诈