主要内容

fillmissing

替换信用记分卡预测器的缺失值

描述

例子

sc= fillmissing (scPredictorNames统计数据替换预测器的缺失值PredictorNames用定义的值统计数据并返回一个更新的信用记分卡对象(sc).标准缺失数据定义如下:

  • 对于数字数组

  • <定义>对于分类数组

请注意

如果你跑fillmissing在对预测器进行装箱后,现有的切割点和装箱边被保留,“好的”和“坏的”计数从< >失踪Bin被添加到相应的Bin中。

例子

sc= fillmissing (___ConstantValue使用前面语法中的参数和一个值ConstantValue替换丢失的值。

例子

全部折叠

这个例子展示了如何使用fillmissing控件中缺失的值CustAge而且ResStatus具有用户定义值的预测器。有关“处理”丢失数据的其他方法的更多信息,请参见缺少值的信用记分卡建模

加载信用记分卡数据并使用dataMissing训练数据。

负载CreditCardData.matdisp(头(dataMissing));
CustID CustAge TmAtAddress ResStatus EmpStatus CustIncome TmWBank OtherCC AMBalance UtilRate地位  ______ _______ ___________ ___________ _________ __________ _______ _______ _________ ________ ______ 53 62 <定义>未知50000 55是的1055.9 - 0.22 0 2 61 22业主雇佣52000 25是的1161.6 - 0.24 0 3 47 30租户使用37000 61没有877.23 - 0.29 0 4南75业主雇佣了53000 20是的157.37 - 0.08 0 5 68 56家老板雇用了53000名14是的561.84 - 0.11 0 6 65 13业主使用48000 59 Yes 968.18 0.15 0 7 34 32 Home Owner Unknown 32000 26 Yes 717.82 0.02 1 8 50 57 Other Employed 51000 33 No 3041.2 0.13 0

创建一个creditscorecard对象与“BinMissingData”设置为真正的

sc = creditscorecard(dataMissing,“BinMissingData”,真正的);Sc = autobinning(Sc);

使用bininfo而且plotbins来显示CustAge而且ResStatus数据缺失的预测器。

bininfo (sc,“CustAge”
ans =10×6表Bin Good Bad Odds WOE InfoValue _____________ _____________ ________ __________ {'[-Inf,33)'} 69 52 1.3269 -0.42156 0.018993 {'[32,37)'} 63 45 1.4 -0.36795 0.012839 {'[37,40)'} 72 47 1.5319 -0.2779 0.0079824 {'[40,46)'} 172 89 1.5319 -0.2779 0.0079849 {'[46,46)'} 59 25 2.36 0.15424 0.0016199 {'[46,58)'} 99 41 2.4146 0.17724 0.0035449 {'[46,58)'} 157 62 2.5323 0.22469 0.0088407 {'[58,Inf]'} 93 25 3.72 0.60931 0.032198 {''} 19 11 1.7273 -0.15787 0.00063885{'合计'}803 3972.0227 NaN 0.087112
plotbins (sc,“CustAge”);

{

bininfo (sc,“ResStatus”
ans =5×6表Bin Good Bad Odds WOE InfoValue ______________ _____________ _________ __________ {'Tenant'} 296 161 1.8385 -0.095463 0.0035249 {'Home Owner'} 352 171 2.0585 0.017549 0.00013382 {'Other'} 128 52 2.4615 0.19637 0.0055808 {''} 27 13 2.0769 0.026469 2.3248e-05{'合计'}803 397 2.0227 NaN 0.0092627
plotbins (sc,“ResStatus”);

{

使用fillmissing来代替CustAge用中值替换< >失踪ResStatus“租户”.使用predictorinfo验证填充的值。

Sc = fillmissing(Sc,{“CustAge”},“中值”);Sc = fillmissing(Sc,{“ResStatus”},“不变”“租户”);predictorinfo (sc,“CustAge”
ans =1×4表PredictorType LatestBinning LatestFillMissingType LatestFillMissingValue  _____________ ________________________ _____________________ ______________________ CustAge{‘数字’}{‘自动/单调’}{“中位数”}{[45]}
predictorinfo (sc,“ResStatus”
ans =表1×5PredictorType序数LatestBinning LatestFillMissingType LatestFillMissingValue  _______________ _______ ________________________ _____________________ ______________________ ResStatus{“直言”}假{‘自动/单调’}{“常数”}{“租户”}

使用bininfo而且plotbins来显示CustAge而且ResStatus预测器,以验证缺失的数据是否已替换为定义的值fillmissing

bininfo (sc,“CustAge”
ans =9×6表Bin Good Bad Odds WOE InfoValue _____________ _____________ _________ _________ {'[-Inf,33)'} 69 52 1.3269 -0.42156 0.018993 {'[32,37)'} 63 45 1.4 -0.36795 0.012839 {'[37,40)'} 72 47 1.5319 -0.2779 0.0079824 {'[40,46)'} 191 100 1.91 -0.057315 0.0008042 {'[46,46)'} 59 25 2.36 0.15424 0.0016199 {'[46,51)'} 99 41 2.4146 0.17713 0.0035449 {'[51,58)'} 157 62 2.5323 0.22469 0.0088407 {'[58,Inf]'} 93 25 3.72 0.60931 0.032198{'合计'}803 397 2.0227 NaN 0.086822
plotbins (sc,“CustAge”);

{

bininfo (sc,“ResStatus”
ans =4×6表Bin Good Bad Odds WOE InfoValue ______________ _____________ _________ __________ {'Tenant'} 323 174 1.8563 -0.085821 0.0030935 {'Home Owner'} 352 171 2.0585 0.017549 0.00013382 {'Other'} 128 52 2.4615 0.19637 0.0055808{'合计'}803 397 2.0227 NaN 0.0088081
plotbins (sc,“ResStatus”);

{

使用fitmodel然后跑formatpointsdisplaypoints,分数

Sc = fitmodel(Sc,“显示”“关闭”);Sc =格式化点(Sc,“WorstAndBest”800年[300]);T = displaypoints(sc)
t =31日×3表预测本点  ______________ _________________ ______ {' CustAge’}{[无穷,33)的72.565}{‘CustAge}{[33岁,37)的76.588}{‘CustAge}{[37、40)的83.346}{‘CustAge}{[40岁,46)的99.902}{‘CustAge}{[46岁,48)的115.78}{‘CustAge}{[48, 51)的117.5}{‘CustAge}{[51岁,58)的121.07}{‘CustAge}{[58岁的Inf]的}149.93{‘CustAge}{‘失踪> <}99.902{‘EmpStatus}{‘未知’}79.64{‘EmpStatus}{“雇佣”}133.98{‘EmpStatus}{“失踪> <”}南{‘CustIncome}{[无穷,29000)的}21.926 {'CustIncome'} {'[29000,33000)'} 73.949 {'CustIncome'} {'[33000,35000)'} 97.117 {'CustIncome'} {'[35000,40000)'} 101.44

当验证数据集缺少值时,您使用fillmissing对于训练数据集,验证数据集中缺失的值被分配到与包含填充值的对应箱相同的点。

如表所示,“失踪> <”Bin forCustAge预测器被分配相同的分数“[40岁,46)”Bin,因为缺失的数据用中值填充45

分配给“失踪> <”Bin forEmpStatus预测是因为fillmissing不是用来预测的。分配的点数由默认值决定“NoScore”“失踪”中的名称-值对参数formatpoints

创建一个测试验证数据集(tdata)并添加缺失的值。

Tdata = data(1:10,:);tdata.CustAge(1) = NaN;tdata.ResStatus (2) =' <定义> ';[scr,pts] = score(sc,tdata)
可控硅=10×1566.7335 611.2547 584.5130 628.7876 609.7148 671.1048 403.6413 551.9461 575.9874 524.4789
分=10×5表CustAge EmpStatus CustIncome TmWBank AMBalance _______ _________ __________ _______ _________ 99.902 79.64 153.88 145.38 87.933 149.93 133.98 153.88 85.531 87.933 115.78 133.98 101.44 145.38 87.933 117.5 133.98 153.91 139.93 133.98 153.88 83.991 87.933 139.93 133.98 153.88 145.38 87.933 76.588 79.64 73.949 85.531 87.933 117.5 133.98 153.88 85.531 61.06 117.5 79.64 153.88 85.531 87.933 85.531 87.933

这个例子展示了处理验证数据中缺失数据的不同可能性。

在对来自验证数据集的数据进行评分时,您有几个选项。如果选择什么都不做,那么分配给缺失数据的点为,它来自默认值“NoScore”“失踪”中的名称-值对参数formatpoints

如果您想用一个一致的度量对所有预测器的缺失值进行评分,您可以使用这些选项“ZeroWOE”“MinPoints”,或“MaxPoints”“失踪”中的名称-值对参数formatpoints

负载CreditCardData.matSc =信用记分卡(数据);predictorinfo (sc,“CustAge”
ans =1×4表PredictorType LatestBinning LatestFillMissingType LatestFillMissingValue  _____________ _________________ _____________________ ______________________ CustAge{‘数字’}{“原始数据”}{“原始”}{0 x0双}
predictorinfo (sc,“ResStatus”
ans =表1×5PredictorType序数LatestBinning LatestFillMissingType LatestFillMissingValue  _______________ _______ _________________ _____________________ ______________________ ResStatus{“直言”}假{“原始数据”}{“原始”}{0 x0双}
Sc = autobinning(Sc);Sc = fitmodel(Sc,“显示”“关闭”);displaypoints (sc)
ans =37×3表预测本点  ______________ ________________ _________ {' CustAge’}{[无穷,33)的-0.15894}{‘CustAge}{[33岁,37)的-0.14036}{‘CustAge}{[37、40)的-0.060323}{‘CustAge}{[40岁,46)的0.046408}{‘CustAge}{[46岁,48)的0.21445}{‘CustAge}{[48, 58)的0.23039}{“CustAge”}{的[58岁的Inf]} 0.479{‘CustAge}{“失踪> <”}南{‘ResStatus}{“租户”}-0.031252{‘ResStatus}{‘业主’}0.12696{‘ResStatus}{‘其他’}0.37641{‘ResStatus}{“失踪> <”}南{' EmpStatus '}{'Unknown'} -0.076317 {'EmpStatus'} {'Employed'} 0.31449 {'EmpStatus'} {''} NaN {'CustIncome'} {'[-Inf,29000)'} -0.45716
Sc =格式化点(Sc,“失踪”“minpoints”“WorstAndBestScores”850年[300]);displaypoints (sc)
ans =37×3表预测本点  ______________ ________________ ______ {' CustAge’}{[无穷,33)的46.396}{‘CustAge}{[33岁,37)的48.727}{‘CustAge}{[37、40)的58.772}{‘CustAge}{[40岁,46)的72.167}{‘CustAge}{[46岁,48)的93.256}{‘CustAge}{[48, 58)的95.256}{“CustAge”}{的[58岁的Inf]} 126.46{‘CustAge}{“失踪> <”}46.396{‘ResStatus}{“租户”}62.421{‘ResStatus}{‘业主’}82.276{‘ResStatus}{‘其他’}113.58{‘ResStatus}{“失踪> <”}62.421{‘EmpStatus}{‘未知’}56.765 {'EmpStatus'} {'Employed'} 105.81 {'EmpStatus'} {''} 56.765 {'CustIncome'} {'[-Inf,29000)'} 8.9706

的价值-32.5389< >失踪本的“CustAge”来自于“minPoints”理由formatpoints

[scr,pts] = score(sc,dataMissing(1:5,:))
可控硅=5×1602.0394 648.1988 560.5569 613.5595 646.8109
分=5×7表CustAge ResStatus EmpStatus CustIncome TmWBank OtherCC AMBalance _______ _________ _________ __________ _______ _______ _________ 95.256 62.421 56.765 121.18 116.05 86.224 64.15 126.46 82.276 105.81 121.18 62.107 86.224 64.15 93.256 62.421 105.81 76.585 116.05 42.287 64.15 46.396 82.276 105.81 121.18 60.719 86.224 64.15

或者,您可以根据每个预测器的信息,用不同的统计值为遗漏的数据评分。要做到这一点,使用fillmissing对于一个creditscorecard对象

负载CreditCardData.matSc =信用记分卡(数据);Sc = fillmissing(Sc,“CustAge”“不变”35);predictorinfo (sc,“CustAge”
ans =1×4表PredictorType LatestBinning LatestFillMissingType LatestFillMissingValue  _____________ _________________ _____________________ ______________________ CustAge{‘数字’}{“原始数据”}{“常数”}{[35]}
Sc = fillmissing(Sc,“ResStatus”“模式”);predictorinfo (sc,“ResStatus”
ans =表1×5PredictorType序数LatestBinning LatestFillMissingType LatestFillMissingValue  _______________ _______ _________________ _____________________ ______________________ ResStatus{“直言”}假{“原始数据”}{‘模式’}{‘业主’}
Sc = autobinning(Sc);Sc = fitmodel(Sc,“显示”“关闭”);Sc =格式化点(Sc,“失踪”“minpoints”“WorstAndBestScores”850年[300]);displaypoints (sc)
ans =37×3表预测本点  ______________ ________________ ______ {' CustAge’}{[无穷,33)的46.396}{‘CustAge}{[33岁,37)的48.727}{‘CustAge}{[37、40)的58.772}{‘CustAge}{[40岁,46)的72.167}{‘CustAge}{[46岁,48)的93.256}{‘CustAge}{[48, 58)的95.256}{“CustAge”}{的[58岁的Inf]} 126.46{‘CustAge}{“失踪> <”}48.727{‘ResStatus}{“租户”}62.421{‘ResStatus}{‘业主’}82.276{‘ResStatus}{‘其他’}113.58{‘ResStatus}{“失踪> <”}82.276{‘EmpStatus}{‘未知’}56.765 {'EmpStatus'} {'Employed'} 105.81 {'EmpStatus'} {''} 56.765 {'CustIncome'} {'[-Inf,29000)'} 8.9706

的价值< >失踪“CustAge”的填充值35即使训练数据没有缺失值。

: disp (dataMissing (1:5));
CustID CustAge TmAtAddress ResStatus EmpStatus CustIncome TmWBank OtherCC AMBalance UtilRate status ______ _______ ___________ ___________ _________ __________ _______ _______ _________ ________ ______ 1 53 62  Unknown 50000 55 Yes 1055.9 0.22 0 2 61 22 Home Owner hired 52000 25 Yes 1161.6 0.24 0 3 47 30 Tenant hired 37000 61 No 877.23 0.29 0 4 NaN 75 Home Owner hired 53000 20 Yes 157.37 0.08 05 68 56 Home Owner hired 53000 14 Yes 561.84 0.11 0
[scr,pts] = score(sc,dataMissing(1:5,:))
可控硅=5×1621.8943 648.1988 560.5569 615.8904 646.8109
分=5×7表CustAge ResStatus EmpStatus CustIncome TmWBank OtherCC AMBalance _______ _________ _________ __________ _______ _______ _________ 95.256 82.276 56.765 121.05 86.224 64.15 126.46 82.276 105.81 121.18 62.107 86.224 64.15 93.256 62.421 105.81 76.585 116.05 42.287 64.15 48.727 82.276 105.81 121.18 60.719 86.224 110.96 126.46 82.276 105.81 121.18 60.719 86.224 64.15

输入参数

全部折叠

信用记分卡模型,指定为creditscorecard对象。

的名字creditscorecard用于填充缺失数据的预测器,指定为标量字符向量、标量字符串、字符向量的单元格数组或字符串数组。

数据类型:字符|字符串|细胞

统计数据,用于填充预测器的缺失数据,指定为具有以下值之一的字符向量或字符串。

  • “的意思是”—用平均值或平均值替换缺失的数据。该选项仅对数值数据有效。的“的意思是”计算预测器的加权平均值,参考预测器列和权重列中的creditscorecard对象。有关更多信息,请参见加权平均数

  • “中值”—用中位数替换缺失的数据。对数字和序数数据有效。的“中值”计算预测器的加权中值,参考预测器列和权重列中的creditscorecard对象。有关更多信息,请参见加权中值

  • “模式”—用模式替换缺失的数据。适用于数字、名义和顺序分类数据。的“模式”计算加权模式通过参考预测器列和权重列中的creditscorecard对象。有关更多信息,请参见加权方式

  • “原始”-将数值和类别预测器的缺失数据设置回其原始值:如果数值,<定义>< >失踪如果直言。

  • “不变”—将数值和类别预测器的缺失数据设置为您在可选参数中指定的常量值ConstantValue

数据类型:字符|字符串

中指定的预测器中缺失的项PredictorNames,指定为数值、字符向量、字符串或字符向量的单元格数组。

请注意

你可以用ConstantValue除非你设置统计数据参数“不变”

数据类型:字符||字符串|细胞

输出参数

全部折叠

更新creditscorecard对象,作为对象返回。

更多关于

全部折叠

加权平均数

加权平均数与普通平均值类似,只不过不是每个数据点对最终平均值的贡献相等,而是有些数据点对最终平均值的贡献大于其他数据点。

非空有限多数据集(x)与相应的非负权重(w)是

x ¯ 1 n w x 1 n w

加权中值

加权中位数是50%加权百分位数,其中计算总权重的百分比而不是总数。

n不同有序元素(x)正权重(w如:如此 1 n w 1 ,加权中值为元素xk

1 k 1 w 1 2 而且 k + 1 n w 1 2

如果两个元素的权值都与权值集的中点相邻,但不封装它,则每个元素定义一个等于1/2的分区。这些元素被称为加权中位数和加权中位数。权重中值的选择基于哪个元素使分区最相等。这个中值总是权值最低的加权中值。如果上、下加权中位数相等,则接受下加权中位数。

加权方式

加权方式是一组加权数据值中最常出现的值。

样本的模式是集合中最常出现的元素。例如,样本[1,3,6,6,6,6,7,7,12,12,17]的模式为6。

参考文献

[1]《巴塞尔银行监管委员会:内部评级系统验证研究》。工作文件第14号,2005年2月

[2]快餐,M。信用风险记分卡:使用SAS开发和实现。lulu.com, 2011。

吕夫勒和波施。基于Excel和VBA的信用风险建模。威利金融,2007年。

版本历史

在R2020a中引入