- 信用评分卡分类
A卡:申请评分卡,侧重贷前,在客户获取期,建立信用风险评分,预测客户带来违约风险的概率大小;
B卡:行为评分卡,侧重贷中,在客户申请处理期,建立申请风险评分模型,预测客户开户后一定时期内违约拖欠的风险概率,有效排除了信用不良客户和非目标客户的申请;
C卡:催收评分卡,侧重贷后,在帐户管理期,建立催收评分模型,对逾期帐户预测催收策略反应的概率,从而采取相应的催收措施。
- python 代码
# 评分卡转化
## 前提:WOE转化,逻辑回归各变量系数
## score = A+B*model_score
## 1.给某个特定的比率设定特定的预期分值;设定为p,好坏比设定为15
## 2.比率翻番时下降的分数(PDO)设定为20分
## 3. 基准分数定位700分,分数越大,信用度越好
## 从woe的公式来看,就是逻辑回归中机会比的含义。评分卡模型,对每个类别的woe乘以一个参数和评分权重,最终得到了模型分数。
from math import log
temdf = pd.DataFrame([result.params,round(result.pvalues,4),result.tvalues],index = ['coef','pvalue','z']).T
p = 15 / math.log(2)
q = 700 - 20 * math.log(15) / math.log(2)
print(p,q)
baseScore = round(q - p * temdf['coef'][0], 0)
print(baseScore)
# 第i个变量各区间的分数计算公式: A-B*(alpha/n+betai*woei1)
def trans(p,beta,datawoe):
credit_score = OrderedDict()
n = len(smlogit_summary.iloc[1:,:]['index'].tolist())
for var in smlogit_summary.iloc[1:,:]['index'].tolist():
tem_score = OrderedDict()
coef_ = smlogit_summary[smlogit_summary['index']==var]['coef'].values[0]
for j in dataiv[var].keys():
tem_score.update({str(j):round(-coef_*datawoe[var][j]*p,4)})
credit_score.update({var:tem_score})
return credit_score
trans_score = trans(p,smlogit_summary,datawoe)
lst = []
for i in trans_score.keys():
for j in trans_score[i].keys():
lst.append([i,j,trans_score[i][j]])
## 得到每个变量每个区间对应的分数(字典形式)
# 最后根据每条数据每个变量的得分求得总分即可
def final_score_fun(data_,dict_,variables):
temp_dat = copy.deepcopy(data_)
for variable in variables:
temp_dat[variable] =[dict_[variable][i] if i in dict_[variable].keys() else 0 for i in data_[variable] ]
temp_dat['BaseScore'] = 653
temp_dat['final_score'] = temp_dat[variables+['BaseScore']].apply(lambda x:x.sum(),axis=1)
temp_dat = temp_dat.merge(SCORE_TR[['LOAN_NO','y','SCORE_SMLOGIT','train_test']],left_on = 'LOAN_NO',right_on ='LOAN_NO',how = 'left')
return temp_dat
final_score = final_score_fun(dat_[['LOAN_NO']+smlogit_summary.iloc[1:,:]['index'].tolist()],trans_score,list(trans_score.keys()))
网友评论