金融风控-贷款违约预测-Task02 EDA数据理解

金融风控学习赛

https://tianchi.aliyun.com/competition/entrance/531830/information

一、赛题数据

赛题以预测用户贷款是否违约为任务,数据集报名后可见并可下载,该数据来自某信贷平台的贷款记录,总数据量超过120w,包含47列变量信息,其中15列为匿名变量。为了保证比赛的公平性,将会从中抽取80万条作为训练集,20万条作为测试集A,20万条作为测试集B,同时会对employmentTitle、purpose、postCode和title等信息进行脱敏。

导入数据分析相关库

# 导入标准库
import io, os, sys, types, time, datetime, math, random, requests, subprocess,io, tempfile, math

# 导入第三方库
# 数据处理
import numpy as np
import pandas as pd

# 数据可视化
import matplotlib.pyplot as plt
import missingno
import seaborn as sns 
# from pandas.tools.plotting import scatter_matrix  # No module named 'pandas.tools'
from mpl_toolkits.mplot3d import Axes3D
# plt.style.use('seaborn')  # 改变图像风格
plt.rcParams['font.family'] = ['Arial Unicode MS', 'Microsoft Yahei', 'SimHei', 'sans-serif']  # 解决中文乱码
plt.rcParams['axes.unicode_minus'] = False  # simhei黑体字 负号乱码 解决

# 特征选择和编码
from sklearn.feature_selection import RFE, RFECV
from sklearn.svm import SVR
from sklearn.decomposition import PCA
from sklearn import preprocessing
from sklearn.preprocessing import OneHotEncoder, LabelEncoder, label_binarize # Imputer
# from fancyimpute import BiScaler, KNN, NuclearNormMinimization, SoftImpute

# 机器学习
import sklearn.ensemble as ske
from sklearn import datasets, model_selection, tree, preprocessing, metrics, linear_model
from sklearn.svm import LinearSVC
from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.linear_model import LinearRegression, LogisticRegression, Ridge, Lasso, SGDClassifier
from sklearn.tree import DecisionTreeClassifier

# 网格搜索、随机搜索
import scipy.stats as st
from scipy.stats import randint as sp_randint
from sklearn.model_selection import GridSearchCV
from sklearn.model_selection import RandomizedSearchCV
from sklearn.model_selection import train_test_split

# 模型度量(分类)
from sklearn.metrics import precision_recall_fscore_support, roc_curve, auc

# 警告处理 
import warnings
warnings.filterwarnings('ignore')

# 在Jupyter上画图
%matplotlib inline

# 数据预处理
import numpy as np
import scipy as sc
import scipy.fftpack
import sklearn as sk
import matplotlib.pyplot as plt
import ewtpy
import scipy.fftpack

# 绘图工具包
import seaborn as sns
import pyecharts.options as opts
from pyecharts.charts import Line, Grid

数据集导入

  • train
  • test
# 数据集路径

train_path = 'train.csv'
test_path = 'testA.csv'
dataset_path = './'
data_train_path = dataset_path + train_path
data_test_path = dataset_path + test_path


# 2.数据集csv读入
train = pd.read_csv(data_train_path)
test = pd.read_csv(data_test_path)

二、数据分析

  • 数据总体了解:
    • 读取数据集并了解数据集大小,原始特征维度;
    • 通过info熟悉数据类型;
    • 粗略查看数据集中各特征基本统计量;
  • 缺失值和唯一值:
    • 查看数据缺失值情况
    • 查看唯一值特征情况
  • 深入数据-查看数据类型
    • 类别型数据
    • 数值型数据
      • 离散数值型数据
      • 连续数值型数据
  • 数据间相关关系
    • 特征和特征之间关系
    • 特征和目标变量之间关系
  • 用pandas_profiling生成数据报告

数据集大小和类型

  • train: (800000, 47)
  • test : (200000, 46)

我们可以看到数据量还是比较大的,对内层空间有一定要求

print(train.shape,test.shape)
print('--'*30)
train.info()
print('--'*30)
test.info()
(800000, 47) (200000, 46)
------------------------------------------------------------
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 800000 entries, 0 to 799999
Data columns (total 47 columns):
id                    800000 non-null int64
loanAmnt              800000 non-null float64
term                  800000 non-null int64
interestRate          800000 non-null float64
installment           800000 non-null float64
grade                 800000 non-null object
subGrade              800000 non-null object
employmentTitle       799999 non-null float64
employmentLength      753201 non-null object
homeOwnership         800000 non-null int64
annualIncome          800000 non-null float64
verificationStatus    800000 non-null int64
issueDate             800000 non-null object
isDefault             800000 non-null int64
purpose               800000 non-null int64
postCode              799999 non-null float64
regionCode            800000 non-null int64
dti                   799761 non-null float64
delinquency_2years    800000 non-null float64
ficoRangeLow          800000 non-null float64
ficoRangeHigh         800000 non-null float64
openAcc               800000 non-null float64
pubRec                800000 non-null float64
pubRecBankruptcies    799595 non-null float64
revolBal              800000 non-null float64
revolUtil             799469 non-null float64
totalAcc              800000 non-null float64
initialListStatus     800000 non-null int64
applicationType       800000 non-null int64
earliesCreditLine     800000 non-null object
title                 799999 non-null float64
policyCode            800000 non-null float64
n0                    759730 non-null float64
n1                    759730 non-null float64
n2                    759730 non-null float64
n3                    759730 non-null float64
n4                    766761 non-null float64
n5                    759730 non-null float64
n6                    759730 non-null float64
n7                    759730 non-null float64
n8                    759729 non-null float64
n9                    759730 non-null float64
n10                   766761 non-null float64
n11                   730248 non-null float64
n12                   759730 non-null float64
n13                   759730 non-null float64
n14                   759730 non-null float64
dtypes: float64(33), int64(9), object(5)
memory usage: 286.9+ MB
------------------------------------------------------------
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 200000 entries, 0 to 199999
Data columns (total 46 columns):
id                    200000 non-null int64
loanAmnt              200000 non-null float64
term                  200000 non-null int64
interestRate          200000 non-null float64
installment           200000 non-null float64
grade                 200000 non-null object
subGrade              200000 non-null object
employmentTitle       200000 non-null float64
employmentLength      188258 non-null object
homeOwnership         200000 non-null int64
annualIncome          200000 non-null float64
verificationStatus    200000 non-null int64
issueDate             200000 non-null object
purpose               200000 non-null int64
postCode              200000 non-null float64
regionCode            200000 non-null int64
dti                   199939 non-null float64
delinquency_2years    200000 non-null float64
ficoRangeLow          200000 non-null float64
ficoRangeHigh         200000 non-null float64
openAcc               200000 non-null float64
pubRec                200000 non-null float64
pubRecBankruptcies    199884 non-null float64
revolBal              200000 non-null float64
revolUtil             199873 non-null float64
totalAcc              200000 non-null float64
initialListStatus     200000 non-null int64
applicationType       200000 non-null int64
earliesCreditLine     200000 non-null object
title                 200000 non-null float64
policyCode            200000 non-null float64
n0                    189889 non-null float64
n1                    189889 non-null float64
n2                    189889 non-null float64
n3                    189889 non-null float64
n4                    191606 non-null float64
n5                    189889 non-null float64
n6                    189889 non-null float64
n7                    189889 non-null float64
n8                    189889 non-null float64
n9                    189889 non-null float64
n10                   191606 non-null float64
n11                   182425 non-null float64
n12                   189889 non-null float64
n13                   189889 non-null float64
n14                   189889 non-null float64
dtypes: float64(33), int64(8), object(5)
memory usage: 70.2+ MB
# 字段特征
train.describe()
idloanAmntterminterestRateinstallmentemploymentTitlehomeOwnershipannualIncomeverificationStatusisDefaultpurposepostCoderegionCodedtidelinquency_2yearsficoRangeLowficoRangeHighopenAccpubRecpubRecBankruptciesrevolBalrevolUtiltotalAccinitialListStatusapplicationTypetitlepolicyCoden0n1n2n3n4n5n6n7n8n9n10n11n12n13n14
count800000.000000800000.000000800000.000000800000.000000800000.000000799999.000000800000.0000008.000000e+05800000.000000800000.000000800000.000000799999.000000800000.000000799761.000000800000.000000800000.000000800000.000000800000.000000800000.000000799595.0000008.000000e+05799469.000000800000.000000800000.000000800000.000000799999.000000800000.0759730.000000759730.000000759730.000000759730.000000766761.000000759730.000000759730.000000759730.000000759729.000000759730.000000766761.000000730248.000000759730.000000759730.000000759730.000000
mean399999.50000014416.8188753.48274513.238391437.94772372005.3517140.6142137.613391e+041.0096830.1995131.745982258.53564816.38575818.2845570.318239696.204081700.20422611.5980200.2149150.1341631.622871e+0451.79073424.9988610.4169530.0192671754.1135891.00.5119323.6423305.6426485.6426484.7356418.1079378.5759948.28295314.6224885.59234511.6438960.0008150.0033840.0893662.178606
std230940.2520138716.0861780.8558324.765757261.460393106585.6402040.6757496.894751e+040.7827160.3996342.367453200.03744611.03667911.1501550.88032531.86599531.8666745.4752860.6064670.3774712.245802e+0424.51612611.9992010.4930550.1374647941.4740400.01.3332662.2468253.3028103.3028102.9499694.7992107.4005364.5616898.1246103.2161845.4841040.0300750.0620410.5090691.844377
min0.000000500.0000003.0000005.31000015.6900000.0000000.0000000.000000e+000.0000000.0000000.0000000.0000000.000000-1.0000000.000000630.000000634.0000000.0000000.0000000.0000000.000000e+000.0000002.0000000.0000000.0000000.0000001.00.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000001.0000000.0000000.0000000.0000000.0000000.0000000.000000
25%199999.7500008000.0000003.0000009.750000248.450000427.0000000.0000004.560000e+040.0000000.0000000.000000103.0000008.00000011.7900000.000000670.000000674.0000008.0000000.0000000.0000005.944000e+0333.40000016.0000000.0000000.0000000.0000001.00.0000002.0000003.0000003.0000003.0000005.0000004.0000005.0000009.0000003.0000008.0000000.0000000.0000000.0000001.000000
50%399999.50000012000.0000003.00000012.740000375.1350007755.0000001.0000006.500000e+041.0000000.0000000.000000203.00000014.00000017.6100000.000000690.000000694.00000011.0000000.0000000.0000001.113200e+0452.10000023.0000000.0000000.0000001.0000001.00.0000003.0000005.0000005.0000004.0000007.0000007.0000007.00000013.0000005.00000011.0000000.0000000.0000000.0000002.000000
75%599999.25000020000.0000003.00000015.990000580.710000117663.5000001.0000009.000000e+042.0000000.0000004.000000395.00000022.00000024.0600000.000000710.000000714.00000014.0000000.0000000.0000001.973400e+0470.70000032.0000001.0000000.0000005.0000001.00.0000005.0000007.0000007.0000006.00000011.00000011.00000010.00000019.0000007.00000014.0000000.0000000.0000000.0000003.000000
max799999.00000040000.0000005.00000030.9900001715.420000378351.0000005.0000001.099920e+072.0000001.00000013.000000940.00000050.000000999.00000039.000000845.000000850.00000086.00000086.00000012.0000002.904836e+06892.300000162.0000001.0000001.00000061680.0000001.051.00000033.00000063.00000063.00000049.00000070.000000132.00000079.000000128.00000045.00000082.0000004.0000004.00000039.00000030.000000
test.describe()
idloanAmntterminterestRateinstallmentemploymentTitlehomeOwnershipannualIncomeverificationStatuspurposepostCoderegionCodedtidelinquency_2yearsficoRangeLowficoRangeHighopenAccpubRecpubRecBankruptciesrevolBalrevolUtiltotalAccinitialListStatusapplicationTypetitlepolicyCoden0n1n2n3n4n5n6n7n8n9n10n11n12n13n14
count200000.000000200000.000000200000.000000200000.000000200000.000000200000.000000200000.0000002.000000e+05200000.000000200000.000000200000.000000200000.000000199939.000000200000.000000200000.000000200000.000000200000.000000200000.00000199884.0000002.000000e+05199873.000000200000.000000200000.000000200000.000000200000.000000200000.0189889.000000189889.000000189889.000000189889.000000191606.000000189889.000000189889.000000189889.000000189889.000000189889.000000191606.000000182425.000000189889.000000189889.000000189889.000000
mean899999.50000014436.9541253.48169013.244800438.73780472435.7507400.6141007.645184e+041.0104301.744410258.25953516.43083018.2912820.315895696.166400700.16653011.5803400.215530.1352931.625583e+0451.87512124.9218100.4166500.0194651778.1805701.00.5078653.6481105.6471415.6471414.7325458.0939768.5273348.27484014.5925515.59629611.6268910.0008330.0036180.0883412.180316
std57735.1712568737.4303260.8551954.766528262.246698106892.3749330.6754657.766237e+040.7817322.367497199.75221411.06127911.4938060.87631631.85261931.8532285.4555250.606530.3806652.243082e+0424.55584911.9436280.4930050.1381537983.2479150.01.3150192.2577793.3085883.3085882.9593864.8037597.3031064.5509028.1093573.2209785.4646190.0305160.0642760.5051611.841987
min800000.000000500.0000003.0000005.31000014.0100000.0000000.0000000.000000e+000.0000000.0000000.0000000.0000000.0000000.000000625.000000629.0000000.0000000.000000.0000000.000000e+000.0000002.0000000.0000000.0000000.0000001.00.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000001.0000000.0000000.0000000.0000000.0000000.0000000.000000
25%849999.7500008000.0000003.0000009.750000248.890000420.0000000.0000004.600000e+040.0000000.000000103.0000008.00000011.8300000.000000670.000000674.0000008.0000000.000000.0000005.940000e+0333.50000016.0000000.0000000.0000000.0000001.00.0000002.0000003.0000003.0000003.0000005.0000004.0000005.0000009.0000003.0000008.0000000.0000000.0000000.0000001.000000
50%899999.50000012000.0000003.00000012.740000375.4300007836.0000001.0000006.500000e+041.0000000.000000203.00000014.00000017.6200000.000000690.000000694.00000011.0000000.000000.0000001.114000e+0452.30000023.0000000.0000000.0000002.0000001.00.0000003.0000005.0000005.0000004.0000007.0000007.0000007.00000013.0000005.00000011.0000000.0000000.0000000.0000002.000000
75%949999.25000020000.0000003.00000015.990000580.942500119739.2500001.0000009.000000e+042.0000004.000000392.00000022.00000024.0800000.000000710.000000714.00000014.0000000.000000.0000001.977925e+0470.80000032.0000001.0000000.0000005.0000001.00.0000005.0000007.0000007.0000006.00000011.00000011.00000010.00000019.0000007.00000014.0000000.0000000.0000000.0000003.000000
max999999.00000040000.0000005.00000030.9900001715.420000378338.0000005.0000009.500000e+062.00000013.000000931.00000050.000000999.00000028.000000845.000000850.00000090.00000061.0000011.0000001.743266e+06366.600000127.0000001.0000001.00000061676.0000001.032.00000032.00000051.00000051.00000063.00000070.00000099.00000083.000000112.00000041.00000090.0000003.0000003.00000025.00000028.000000

字段表

  1. id 为贷款清单分配的唯一信用证标识
  2. loanAmnt 贷款金额
  3. term 贷款期限(year)
  4. interestRate 贷款利率
  5. installment 分期付款金额
  6. grade 贷款等级
  7. subGrade 贷款等级之子级
  8. employmentTitle 就业职称
  9. employmentLength 就业年限(年)
  10. homeOwnership 借款人在登记时提供的房屋所有权状况
  11. annualIncome 年收入
  12. verificationStatus 验证状态
  13. issueDate 贷款发放的月份
  14. purpose 借款人在贷款申请时的贷款用途类别
  15. postCode 借款人在贷款申请中提供的邮政编码的前3位数字
  16. regionCode 地区编码
  17. dti 债务收入比
  18. delinquency_2years 借款人过去2年信用档案中逾期30天以上的违约事件数
  19. ficoRangeLow 借款人在贷款发放时的fico所属的下限范围
  20. ficoRangeHigh 借款人在贷款发放时的fico所属的上限范围
  21. openAcc 借款人信用档案中未结信用额度的数量
  22. pubRec 贬损公共记录的数量
  23. pubRecBankruptcies 公开记录清除的数量
  24. revolBal 信贷周转余额合计
  25. revolUtil 循环额度利用率,或借款人使用的相对于所有可用循环信贷的信贷金额
  26. totalAcc 借款人信用档案中当前的信用额度总数
  27. initialListStatus 贷款的初始列表状态
  28. applicationType 表明贷款是个人申请还是与两个共同借款人的联合申请
  29. earliesCreditLine 借款人最早报告的信用额度开立的月份
  30. title 借款人提供的贷款名称
  31. policyCode 公开可用的策略代码=1新产品不公开可用的策略代码=2
  32. n系列匿名特征 匿名特征n0-n14,为一些贷款人行为计数特征的处理

观察各个字段含义和实际数值

# train.head(20).iloc[:,:13]
train.head(20).iloc[:,13:26]
isDefaultpurposepostCoderegionCodedtidelinquency_2yearsficoRangeLowficoRangeHighopenAccpubRecpubRecBankruptciesrevolBalrevolUtil
011137.03217.050.0730.0734.07.00.00.024178.048.9
100156.01827.830.0700.0704.013.00.00.015096.038.9
200337.01422.770.0675.0679.011.00.00.04606.051.8
304148.01117.210.0685.0689.09.00.00.09948.052.6
4010301.02132.160.0690.0694.012.00.00.02942.032.0
509512.02117.140.0730.0734.019.00.00.04047.031.1
600517.01417.490.0755.0759.012.00.00.03111.08.5
700100.0432.600.0665.0669.08.01.01.014021.059.7
810792.01319.220.0690.0694.015.00.00.027176.046.0
90059.01124.390.0725.0729.07.00.00.02936.030.6
1004134.0814.210.0665.0669.013.00.00.08653.047.5
1100893.04934.630.0710.0714.010.00.00.016343.080.9
1200195.0387.580.0680.0684.012.00.00.018866.035.7
1302134.085.680.0690.0694.07.00.00.04334.068.8
1404167.0838.950.0710.0714.09.00.00.019023.060.8
1502194.03817.270.0660.0664.016.01.01.0220.03.6
1602492.03621.020.0705.0709.016.00.00.036609.061.1
171456.0817.140.0695.0699.05.00.00.05463.076.9
1813140.0828.953.0660.0664.06.00.00.06804.084.0
1900305.01515.550.0700.0704.010.00.00.022859.057.0

查看缺失值

  • 可以看到employmentLength这一字段缺失情况严重
  • 其他非衍生字段缺失值,做一个缺值处理

统计多少字段有缺失值

# 统计多少字段有缺失值
print(f'There are {train.isnull().any().sum()} columns in train dataset with missing values.')
There are 22 columns in train dataset with missing values.

统计超过50%的缺失字段

# 统计是否有超过50%的缺失字段
have_null_fea_dict = (train.isnull().sum()/len(train)).to_dict()
fea_null_moreThanHalf = {}
for key,value in have_null_fea_dict.items():
    if value > 0.5:
        fea_null_moreThanHalf[key] = value
have_null_fea_dict
fea_null_moreThanHalf
{}

缺失值可视化

# 绘图查看缺失值
missingno.bar(train)
<matplotlib.axes._subplots.AxesSubplot at 0x1bd01f2d780>

在这里插入图片描述

缺失率可视化

# nan可视化
missing = train.isnull().sum()/len(train)
missing = missing[missing > 0]
missing.sort_values(inplace=True)
missing.plot.bar()
<matplotlib.axes._subplots.AxesSubplot at 0x1bd26416e48>

缺失率

显然employmentLength字段是非衍生特征里面缺失值非常明显的字段

  • 纵向了解哪些列存在 “nan”, 并可以把nan的个数打印,主要的目的在于查看某一列nan存在的个数是否真的很大,如果nan存在的过多,说明这一列对label的影响几乎不起作用了,可以考虑删掉。如果缺失值很小一般可以选择填充。
  • 另外可以横向比较,如果在数据集中,某些样本数据的大部分列都是缺失的且样本足够的情况下可以考虑删除。
train['employmentLength'].value_counts()
10+ years    262753
2 years       72358
< 1 year      64237
3 years       64152
1 year        52489
5 years       50102
4 years       47985
6 years       37254
8 years       36192
7 years       35407
9 years       30272
Name: employmentLength, dtype: int64

特征类型查看

  • 特征一般都是由类别型特征和数值型特征组成,而数值型特征又分为连续型和离散型。
    • 类别型特征有时具有非数值关系,有时也具有数值关系。比如‘grade’中的等级A,B,C等,是否只是单纯的分类,还是A优于其他要结合业务判断。
    • 数值型特征本是可以直接入模的,但往往风控人员要对其做分箱,转化为WOE编码进而做标准评分卡等操作。从模型效果上来看,特征分箱主要是为了降低变量的复杂性,减少变量噪音对模型的影响,提高自变量和因变量的相关度。从而使模型更加稳定。
numerical_fea = list(train.select_dtypes(exclude=['object']).columns)
category_fea = list(filter(lambda x: x not in numerical_fea,list(train.columns)))
类别型特征:category_fea
category_fea
['grade', 'subGrade', 'employmentLength', 'issueDate', 'earliesCreditLine']
连续型特征:numerical_fea
numerical_fea
['id',
 'loanAmnt',
 'term',
 'interestRate',
 'installment',
 'employmentTitle',
 'homeOwnership',
 'annualIncome',
 'verificationStatus',
 'isDefault',
 'purpose',
 'postCode',
 'regionCode',
 'dti',
 'delinquency_2years',
 'ficoRangeLow',
 'ficoRangeHigh',
 'openAcc',
 'pubRec',
 'pubRecBankruptcies',
 'revolBal',
 'revolUtil',
 'totalAcc',
 'initialListStatus',
 'applicationType',
 'title',
 'policyCode',
 'n0',
 'n1',
 'n2',
 'n3',
 'n4',
 'n5',
 'n6',
 'n7',
 'n8',
 'n9',
 'n10',
 'n11',
 'n12',
 'n13',
 'n14']
Data Type
idID Column
loanAmntNumeric
termCategorical
interestRateNumeric
installmentNumeric
gradeCategorical
subGradeCategorical
employmentTitleNumeric
employmentLengthCategorical
homeOwnershipCategorical
annualIncomeNumeric
verificationStatusCategorical
issueDateDate
isDefaultLabel
purposeCategorical
postCodeNumeric
regionCodeNumeric
dtiNumeric
delinquency_2yearsNumeric
ficoRangeLowNumeric
ficoRangeHighNumeric
openAccNumeric
pubRecNumeric
pubRecBankruptciesCategorical
revolBalNumeric
revolUtilNumeric
totalAccNumeric
initialListStatusCategorical
applicationTypeCategorical
earliesCreditLineDate
titleNumeric
policyCodeNumeric
n0Numeric
n1Numeric
n2Numeric
n3Numeric
n4Numeric
n5Numeric
n6Numeric
n7Numeric
n8Numeric
n9Numeric
n10Numeric
n11Categorical
n12Categorical
n13Numeric
n14Numeric

分离数值型特征

数值型特征包含连续性和离散型

# 过滤数值型类别特征
def get_numerical_serial_fea(data,feas):
    numerical_serial_fea = []
    numerical_noserial_fea = []
    for fea in feas:
        temp = data[fea].nunique()
        if temp <= 10:
            numerical_noserial_fea.append(fea)
            continue
        numerical_serial_fea.append(fea)
    return numerical_serial_fea,numerical_noserial_fea
numerical_serial_fea,numerical_noserial_fea = get_numerical_serial_fea(train,numerical_fea)
# 连续型
numerical_serial_fea
['id',
 'loanAmnt',
 'interestRate',
 'installment',
 'employmentTitle',
 'annualIncome',
 'purpose',
 'postCode',
 'regionCode',
 'dti',
 'delinquency_2years',
 'ficoRangeLow',
 'ficoRangeHigh',
 'openAcc',
 'pubRec',
 'pubRecBankruptcies',
 'revolBal',
 'revolUtil',
 'totalAcc',
 'title',
 'n0',
 'n1',
 'n2',
 'n3',
 'n4',
 'n5',
 'n6',
 'n7',
 'n8',
 'n9',
 'n10',
 'n13',
 'n14']
# 离散型
numerical_noserial_fea
['term',
 'homeOwnership',
 'verificationStatus',
 'isDefault',
 'initialListStatus',
 'applicationType',
 'policyCode',
 'n11',
 'n12']

数值连续型变量分析

#每个数字特征得分布可视化
f = pd.melt(train, value_vars=numerical_serial_fea)
g = sns.FacetGrid(f, col="variable",  col_wrap=2, sharex=False, sharey=False)
g = g.map(sns.distplot, "value")

在这里插入图片描述

  • 查看某一个数值型变量的分布,查看变量是否符合正态分布,如果不符合正太分布的变量可以log化后再观察下是否符合正态分布。
  • 如果想统一处理一批数据变标准化 必须把这些之前已经正态化的数据提出
  • 正态化的原因:一些情况下正态化非正态特征可以让模型更快的收敛,一些模型要求数据正态(eg. GMM、KNN),保证数据不要过偏态即可,过于偏态可能会影响模型预测结果。
#Ploting Transaction Amount Values Distribution
plt.figure(figsize=(16,12))
plt.suptitle('Transaction Values Distribution', fontsize=22)
plt.subplot(221)
sub_plot_1 = sns.distplot(train['loanAmnt'])
sub_plot_1.set_title("loanAmnt Distribuition", fontsize=18)
sub_plot_1.set_xlabel("")
sub_plot_1.set_ylabel("Probability", fontsize=15)

plt.subplot(222)
sub_plot_2 = sns.distplot(np.log(train['loanAmnt']))
sub_plot_2.set_title("loanAmnt (Log) Distribuition", fontsize=18)
sub_plot_2.set_xlabel("")
sub_plot_2.set_ylabel("Probability", fontsize=15)
Text(0, 0.5, 'Probability')

在这里插入图片描述

总结

  • 数据理解和数据处理是数据挖掘极其重要的一环,我们需要了解数据集各个字段的特点并加以处理

三、评测标准

提交结果为每个测试样本是1的概率,也就是y为1的概率。评价方法为AUC评估模型效果(越大越好)。

分类常用使用的评估指标是:

  • Accuracy(精确度),AUC,Recall(召回率),Precision(准确度),F1,Kappa

本次是学习赛使用的评估指标是AUC

  • AUC也就是ROC曲线下与坐标轴围成的面积
  • ROC空间将假正例率(FPR)定义为 X 轴,真正例率(TPR)定义为 Y 轴。
    • TPR:在所有实际为正例的样本中,被正确地判断为正例之比率。
    • FPR:在所有实际为负例的样本中,被错误地判断为正例之比率。
  • AUC的取值范围子是0.5和1之间,面积越大,精准度越高,因此AUC越接近1.0,模型精准率预告,AUC为1时精准率为100%,

三、结果提交

提交前请确保预测结果的格式与sample_submit.csv中的格式一致,以及提交文件后缀名为csv。

拍贷“魔镜风控系统”从平均 拍贷“魔镜风控系统”从平均 拍贷“魔镜风控系统”从平均 拍贷“魔镜风控系统”从平均 拍贷“魔镜风控系统”从平均 拍贷“魔镜风控系统”从平均 拍贷“魔镜风控系统”从平均 拍贷“魔镜风控系统”从平均 400 个数据维度评估用户当前的信状态,给每借款 个数据维度评估用户当前的信状态,给每借款 个数据维度评估用户当前的信状态,给每借款 个数据维度评估用户当前的信状态,给每借款 个数据维度评估用户当前的信状态,给每借款 个数据维度评估用户当前的信状态,给每借款 个数据维度评估用户当前的信状态,给每借款 个数据维度评估用户当前的信状态,给每借款 个数据维度评估用户当前的信状态,给每借款 个数据维度评估用户当前的信状态,给每借款 人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个人打出当前状态的 信用分,在此基础上再结合新发标息对于每个6个月内逾 个月内逾 期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来期率的预测 ,为投资人提供关键决策依据。本次竞赛目标是根用户历史行数来用户在未来 用户在未来 用户在未来 6个月内是否会逾期还款的概率。 个月内是否会逾期还款的概率。 个月内是否会逾期还款的概率。 个月内是否会逾期还款的概率。 个月内是否会逾期还款的概率。 个月内是否会逾期还款的概率。 个月内是否会逾期还款的概率。 问题转换成 问题转换成 问题转换成 2分类问题,评估指标为 分类问题,评估指标为 分类问题,评估指标为 分类问题,评估指标为 分类问题,评估指标为 分类问题,评估指标为 分类问题,评估指标为 AUC ,从 Master Master Master,LogInfoLogInfo LogInfo ,UpdateInfo UpdateInfo UpdateInfo 表中构建 表中构建 特征,考虑评估指标为 特征,考虑评估指标为 特征,考虑评估指标为 特征,考虑评估指标为 特征,考虑评估指标为 AUC AUC,其本质是排序优化问题,所以我们在模型顶层融合也使用基于 ,其本质是排序优化问题所以我们在模型顶层融合也使用基于 ,其本质是排序优化问题所以我们在模型顶层融合也使用基于 ,其本质是排序优化问题所以我们在模型顶层融合也使用基于 ,其本质是排序优化问题所以我们在模型顶层融合也使用基于 ,其本质是排序优化问题所以我们在模型顶层融合也使用基于 ,其本质是排序优化问题所以我们在模型顶层融合也使用基于 ,其本质是排序优化问题所以我们在模型顶层融合也使用基于 ,其本质是排序优化问题所以我们在模型顶层融合也使用基于 ,其本质是排序优化问题所以我们在模型顶层融合也使用基于 ,其本质是排序优化问题所以我们在模型顶层融合也使用基于 ,其本质是排序优化问题所以我们在模型顶层融合也使用基于 ,其本质是排序优化问题所以我们在模型顶层融合也使用基于 ,其本质是排序优化问题所以我们在模型顶层融合也使用基于 ,其本质是排序优化问题所以我们在模型顶层融合也使用基于 排序优化的 排序优化的 排序优化的 RANK_AVG RANK_AVG RANK_AVG融合方法。 融合方法。 融
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值