项目实训写实记录No.11

1.信用评分卡的建立

对于ScorecardsData数据集,假设比例即违约与正常比v为1/70 PDD设置为30
则根据
B=PDD/log(2)
A=Z+Blog(v)

在这里插入图片描述
令c为logistic模型的截距项
coef为回归参数的列表
基础分数为A-B
c
每种特征的各个区间:Bcoefwoe(woe为该数据区间的woe值coef为该特征的回归参数)

2.代码实现

'''
评分卡计算
'''
def scorecard_cal(model,df):
    '''假设比例即违约与正常比v为1/70,此时预期分值Z700PDD(比率翻倍的分数)为30
    B=PDD/log(2)
    A=Z+B*log(v)
    '''
    #计算AB
    B=30/np.log(2)
    A=700+B*np.log(1/70)

    #计算基础分值A-BP0,参考上文
    c=model.intercept_ #输出logistic模型的截距项
    coef=model.coef_   #输出回归参数
    BaseScore=A-B*c    #计算基础分值

    x1 = woe_iv(x=df['age'],
               y=df['SeriousDlqin2yrs'])
    x2 = woe_iv(x=df['NumberOfTime30-59DaysPastDueNotWorse'],
               y=df['SeriousDlqin2yrs'])
    x3 = woe_iv(x=df['DebtRatio'],
               y=df['SeriousDlqin2yrs'])
    x4 = woe_iv(x=df['NumberOfOpenCreditLinesAndLoans'],
               y=df['SeriousDlqin2yrs'])
    x5 = woe_iv(x=df['NumberRealEstateLoansOrLines'],
               y=df['SeriousDlqin2yrs'])
    x6 = woe_iv(x=df['NumberOfDependents'],
               y=df['SeriousDlqin2yrs'])
    x7 = woe_iv(x=df['MonthlyIncome_rf'],
               y=df['SeriousDlqin2yrs'])


    scorex1=get_score(x1,coef[0][6],B)
    scorex1.to_excel('dataset/年龄.xls', index=False)
    scorex2=get_score(x2,coef[0][5],B)
    scorex2.to_excel('dataset/逾期30-59天笔数.xls', index=False)
    scorex3=get_score(x3,coef[0][4],B)
    scorex3.to_excel('dataset/负债率.xls', index=False)
    scorex4=get_score(x4,coef[0][3],B)
    scorex4.to_excel('dataset/信贷数量.xls',index=False)
    scorex5=get_score(x5,coef[0][2],B)
    scorex5.to_excel('dataset/固定资产贷款量.xls', index=False)
    scorex6=get_score(x6,coef[0][1],B)
    scorex6.to_excel('dataset/家属数量.xls', index=False)
    scorex7=get_score(x7,coef[0][0],B)
    scorex7.to_excel('dataset/月收入.xls', index=False)

    print("年龄\n",scorex1)
    print("逾期30-59天笔数\n",scorex2)
    print("负债率\n",scorex3)
    print("信贷数量\n",scorex4)
    print("固定资产贷款量\n",scorex5)
    print("家属数量\n",scorex6)
    print("月收入\n",scorex7)
    print('基础值为:',BaseScore)

3.最终建立的评分卡

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值