compactCreditScorecard
对象的工作流
此示例显示了创建对象的工作流compactCreditScorecard
对象的creditscorecard
对象。
步骤1。创建一个creditscorecard
对象
要创建compactCreditScorecard
对象时,必须首先创建creditscorecard
对象。创建一个creditscorecard
对象的CreditCardData.mat
文件,并设置名称-值对参数“BinMissingData”
来真正的
因为dataMissing
数据集包含缺失数据。
负载CreditCardData.matsc =信用记分卡(数据丢失,“IDVar”,“CustID”,“BinMissingData”,真正的);Sc = autobinning(Sc);Sc = modifybins(Sc,“CustAge”,“MinValue”, 0);Sc = modifybins(Sc,“CustIncome”,“MinValue”, 0);
步骤2。拟合logistic回归模型creditscorecard
对象
使用fitmodel
使用证据权重(WOE)数据拟合逻辑回归模型。
[sc, mdl] = fitmodel(sc);
1.添加CustIncome, Deviance = 1490.8527, Chi2Stat = 32.588614, PValue = 1.1387992e-08添加TmWBank, Deviance = 1467.1415, Chi2Stat = 23.711203, PValue = 1.1192909e-063 .添加AMBalance, Deviance = 1455.5715, Chi2Stat = 11.569967, PValue = 0.00067025601。5.添加EmpStatus, Deviance = 1447.3451, Chi2Stat = 8.2264038, PValue = 0.0041285257。添加CustAge, Deviance = 1442.8477, Chi2Stat = 4.4974731, PValue = 0.0339449797.添加ResStatus, Deviance = 1438.9783, Chi2Stat = 3.86941, PValue = 0.049173805。添加OtherCC, Deviance = 1434.9751, Chi2Stat = 4.0031966, PValue = 0.045414057广义线性回归模型:状态~[7个预测因子中有8项的线性公式]分布=二项估计系数:估计SE tStat pValue ________ ________ ______ __________(拦截)0.70229 0.063959 10.98 4.7498e-28 CustAge 0.57421 0.25708 2.2335 0.025513 ResStatus 1.3629 0.66952 2.0356 0.04179 EmpStatus 0.88373 0.2929 3.0172 0.002551 CustIncome 0.73535 0.2159 3.406 0.00065929 TmWBank 1.1065 0.23267 4.7556 1.9783e-06 OtherCC 1.0648 0.52826 2.0156 0.043841 AMBalance 1.0446 0.32197 3.2443 0.0011775 1200观测值,1192误差自由度离散度:1 Chi^2统计与常量模型:88.5, p-value = 2.55e-16
步骤3。创建用于评分的新数据集creditscorecard
对象
创建一个新的数据集,用于根据先前创建的数据进行评分creditscorecard
对象。
tdata = data(1:10, mdl.PredictorNames);tdata.CustAge(2) = NaN;tdata.CustAge(5) = -5;tdata.ResStatus (1) =' <定义> ';tdata.ResStatus (3) =“房东”;tdata.EmpStatus (3) =' <定义> ';tdata.CustIncome(4) = NaN;tdata.EmpStatus (7) =“自由职业者”;tdata.CustIncome(8) = -1;tdata.CustIncome(4) = NaN;disp (tdata);
CustAge ResStatus EmpStatus CustIncome TmWBank OtherCC AMBalance _______ ___________ ___________ __________ _______ _______ _________ 53 <定义>未知50000 55是的1055.9南业主雇用了52000名25 1161.6 47房东<未定义> 37000 61没有877.23业主雇佣南20是的业主雇用了53000名14是的561.84 157.37 65业主雇用了48000名59岁是的968.18 34业主自由职业者32000 26是的717.82其他50雇佣1 33不3041.2 50租户未知52000 25是的115.56 49 Home Owner Unknown 53000 23 Yes 718.5
使用displaypoints
显示每个预测器的点数。使用分数
使用新数据计算信用评分(tdata
).然后使用probdefault
根据新数据(tdata
)来计算违约的概率。当使用formatpoints
,“失踪”
名称-值对参数设置为“minpoints”
因为tdata
包含丢失的数据。
积分信息= displaypoints(sc)
PointsInfo =38×3表预测本点 _____________ ______________ _________ {' CustAge’}{[0,33)的-0.14173}{‘CustAge}{[33岁,37)的-0.11095}{‘CustAge}{[37、40)的-0.059244}{‘CustAge}{[40岁,46)的0.074167}{‘CustAge}{[46岁,48)的0.1889}{‘CustAge}{[48, 51)的0.20204}{‘CustAge}{[51岁,58)的0.22935}{‘CustAge}{[58岁的Inf]的}0.45019{‘CustAge}{‘失踪> <}0.0096749{‘ResStatus}{“租户”}-0.029778{‘ResStatus}{‘业主’}0.12425{‘ResStatus}{‘其他’}0.36796 {' ResStatus '}{'<缺少>'}0.1364 {'EmpStatus'}{'未知'}-0.075948 {'EmpStatus'}{'已雇用'}0.31401 {'EmpStatus'}{'<缺少>'}NaN `
[score, Points] = score(sc, tdata)
成绩=10×11.2784 1.0071 NaN NaN 0.9960 1.8771 NaN NaN 1.0283 0.8095
点=10×7表CustAge ResStatus EmpStatus CustIncome TmWBank OtherCC AMBalance _________ _________ _________ __________ _________ ________ _________ 0.22935 0.1364 -0.075948 0.45309 0.3958 0.15715 -0.017438 0.15715 -0.017438 0.1889 0.1364 NaN 0.080697 0.3958 -0.18537 -0.017438 0.20204 0.12425 0.31401 0.45309 -0.044701 0.15715 0.45309 0.3958 0.15715 -0.017438 -0.11095 0.12425NaN -0.11452 -0.033652 0.15715 -0.017438 0.20204 0.36796 0.31401 NaN -0.033652 -0.18537 -0.21195 0.20204 -0.029778 -0.075948 0.45309 -0.033652 0.15715 0.35539 0.20204 0.12425 -0.075948 0.45309 -0.033652 0.15715 -0.017438
Pd = probdefault(sc, tdata)
pd =10×10.2178 0.2676 NaN NaN 0.2697 0.1327 NaN NaN 0.2634 0.3080
Sc = formatpoints(Sc,“BasePoints”,真的,“失踪”,“minpoints”,“圆”,“finalscore”,“PointsOddsAndPDO”,[500, 2, 50]);PointsInfo1 = displaypoints(sc)
PointsInfo1 =39×3表预测本点 ______________ ______________ _______ {' BasePoints}{‘BasePoints} 500.66{‘CustAge}{-17.461的[0,33)}{‘CustAge}{[33岁,37)的-15.24{‘CustAge}}{[37、40)的-11.511}{“CustAge”}{'[40岁,46)}-1.8871{‘CustAge}{6.3888[46, 48)}{‘CustAge}{[48, 51)的7.3367}{“CustAge”}{[51岁,58)的9.3068}{‘CustAge}{的[58岁的Inf]} 25.238{‘CustAge}{‘失踪> <}-6.5392{‘ResStatus}{“租户”}-9.3852{‘ResStatus}{‘业主’}1.7253{‘ResStatus}{'其他'}19.305 {'ResStatus'}{'<缺失>'}2.6022 {'EmpStatus'} {'Unknown'} -12.716 {'EmpStatus'} {'Employed'} 15.414
[Scores1, Points1] = score(sc, tdata)
Scores1 =10×1542 523 488 495 522 585 445 448 524 508
里=10×8表BasePoints CustAge ResStatus EmpStatus CustIncome TmWBank OtherCC AMBalance __________ _______ _________ _________ __________ _______ _______ _________ 500.66 9.3068 2.6022 -12.716 25.446 21.314 4.0988 -8.495 500.66 -6.5392 1.7253 15.446 -9.6646 4.0988 -8.495 500.66 6.3888 2.6022 -12.716 -1.4161 21.314 -20.609 - 8.4161 21.314 - 20.3367 1.7253 15.414 -42.148 -10.462 4.0988 18.399 500.66 -6.5392 1.7253 15.414 25.446 -10.462 4.0988 -8.495 500.66 25.238 1.7253 15.414 25.446 21.314 4.0914 4.0988 4.0988 -8.495500.66 -15.24 1.7253 -12.716 -15.498 -9.6646 4.0988 -8.495 500.66 7.3367 19.305 15.414 -42.148 -9.6646 -20.609 -22.526 500.66 7.3367 -9.3852 -12.716 25.446 4.0988 18.399 500.66 7.3367 1.7253 -12.716 25.446 -9.6646 4.0988 -8.495
Pd1 = probdefault(sc, tdata)
pd1 =10×10.2178 0.2676 0.3721 0.3488 0.2697 0.1327 0.5178 0.5077 0.2634 0.3080
步骤4。创建一个compactCreditScorecard
对象的creditscorecard
对象
创建一个compactCreditScorecard
对象使用creditscorecard
对象作为输入。或者,您可以创建compactCreditScorecard
对象使用紧凑的
在财务工具箱™中的功能。
csc = compactCreditScorecard(sc)
csc = compactCreditScorecard属性:描述:“GoodLabel: 0 ResponseVar: 'status' WeightsVar:”NumericPredictors: {'CustAge' 'CustIncome' 'TmWBank' 'AMBalance'}类别predictors: {'ResStatus' 'EmpStatus' 'OtherCC'} PredictorVars: {1x7 cell}
第5步。使用关联函数来分析compactCreditScorecard
对象
可以使用。分析compactCreditScorecard对象displaypoints
,分数
,probdefault
来自风险管理工具箱™。
PointsInfo2 = displaypoints(csc)
PointsInfo2 =39×3表预测本点 ______________ ______________ _______ {' BasePoints}{‘BasePoints} 500.66{‘CustAge}{-17.461的[0,33)}{‘CustAge}{[33岁,37)的-15.24{‘CustAge}}{[37、40)的-11.511}{“CustAge”}{'[40岁,46)}-1.8871{‘CustAge}{6.3888[46, 48)}{‘CustAge}{[48, 51)的7.3367}{“CustAge”}{[51岁,58)的9.3068}{‘CustAge}{的[58岁的Inf]} 25.238{‘CustAge}{‘失踪> <}-6.5392{‘ResStatus}{“租户”}-9.3852{‘ResStatus}{‘业主’}1.7253{‘ResStatus}{'其他'}19.305 {'ResStatus'}{'<缺失>'}2.6022 {'EmpStatus'} {'Unknown'} -12.716 {'EmpStatus'} {'Employed'} 15.414
[Scores2, Points2] = score(csc, tdata)
Scores2 =10×1542 523 488 495 522 585 445 448 524 508
Points2 =10×8表BasePoints CustAge ResStatus EmpStatus CustIncome TmWBank OtherCC AMBalance __________ _______ _________ _________ __________ _______ _______ _________ 500.66 9.3068 2.6022 -12.716 25.446 21.314 4.0988 -8.495 500.66 -6.5392 1.7253 15.446 -9.6646 4.0988 -8.495 500.66 6.3888 2.6022 -12.716 -1.4161 21.314 -20.609 - 8.4161 21.314 - 20.3367 1.7253 15.414 -42.148 -10.462 4.0988 18.399 500.66 -6.5392 1.7253 15.414 25.446 -10.462 4.0988 -8.495 500.66 25.238 1.7253 15.414 25.446 21.314 4.0914 4.0988 4.0988 -8.495500.66 -15.24 1.7253 -12.716 -15.498 -9.6646 4.0988 -8.495 500.66 7.3367 19.305 15.414 -42.148 -9.6646 -20.609 -22.526 500.66 7.3367 -9.3852 -12.716 25.446 4.0988 18.399 500.66 7.3367 1.7253 -12.716 25.446 -9.6646 4.0988 -8.495
Pd2 = probdefault(csc, tdata)
pd2 =10×10.2178 0.2676 0.3721 0.3488 0.2697 0.1327 0.5178 0.5077 0.2634 0.3080
比较的大小creditscorecard
而且compactCreditScorecard
对象。
谁(“dataMissing”,“sc”,csc的)
名称大小字节类属性csc 1x1 39598 compactCreditScorecard dataMissing 1200x11 84603表sc 1x1 166575 creditscorecard
的大小compactCreditScorecard
对象是轻量级的creditscorecard
对象。然而,compactCreditScorecard
对象不能直接修改。如果您需要更改acompactCreditScorecard
对象,必须更改起始creditscorecard
对象,然后重新转换该对象以创建compactCreditScorecard
对象了。
另请参阅
creditscorecard
|screenpredictors
|autobinning
|bininfo
|predictorinfo
|modifypredictor
|modifybins
|bindata
|plotbins
|fitmodel
|displaypoints
|formatpoints
|分数
|setmodel
|probdefault
|validatemodel