必威体育Betway必威体育官网
当前位置:首页 > IT技术

R语言 scorecard包 评分卡

时间:2019-11-05 14:15:44来源:IT技术作者:seo实验室小编阅读:87次「手机版」
 

scorecard

library(scorecard)

data("germancredit")

print(dim(germancredit))

print(names(germancredit))

print(head(germancredit[,20:21]))

# 变量选择

dt_s <- var_filter(germancredit, y="creditability")

print(dim(dt_s))

# 数据集划分为训练集和测试集

dt_list <- split_df(dt_s)

train <- dt_list$train

test <- dt_list$test

# woe 分箱 自动分箱

bins <- woebin(dt_s, y="creditability")

# 绘制分箱后的坏账率可视化,对应14张图,这里只展示最后一张

woebin_plot(bins)

train_woe <-  woebin_ply(train, bins)

test_woe <-  woebin_ply(test, bins)

print(dim(train_woe))

print(dim(test_woe))

m1 <- glm( creditability ~ ., family = binomial(), data = train_woe)

summary(m1)

# 逐步回归选择变量

m_step <- step(m1, direction="both", trace = FALSE)

m2 <- eval(m_step$call)

summary(m2)

# 模型性能验证 ks和roc

# 预测的概率

train_pred <- predict(m2, train_woe, type = 'response')

test_pred <- predict(m2, test_woe, type = 'response')

# 性能

train_perf <- perf_eva(train$creditability, train_pred, title = 'train')

test_perf <- perf_eva(test$creditability, test_pred, title = 'test')

# 生成评分卡

card <- scorecard(bins, m2)

card

train_score <- scorecard_ply(train, card, print_step = 0)

# 验证集评分

test_score <- scorecard_ply(test, card, print_step = 0)

print(train_score)

print(test_score)

# 模型的稳定性度量

# psi

psi_result <- perf_psi(

score = list(train = train_score, test = test_score),

label = list(train = train$creditability, test = test$creditability)

)

文章最后发布于: 2018-08-05 17:49:25

相关阅读

数据结构与算法分析-C++描述 第7章 插入排序(insertion

插入排序(insertionSort):       插入排序是最简单的排序算法之一。插入排序由趟排序组成,对于到,插入排序保证从位置0到上的元素已

.NET Framework 4.5 降级至.NET Framework 4.0

由于虚拟主机版本只有.NET Framework 4.0 所以遇到需要降级版本,降级版本都是心酸泪,网上这方面的资料也很少,所以总结一下经验分享:

window location href

window.location.href="/":返回首页; "/":是根目录  服务器上根目录下 默认打开index页面

Curriculum Learning

从一篇论文学习“课程学习”,着重关注Curriculum Learning,在此简单记录相关内容。 论文题目:Curriculum Learning for Natural Ans

strtoul函数的用法

头文件:#include <stdlib.h>strtoul() 函数源自于“string to unsigned long”,用来将字符串转换成无符号长整型数(unsigned long),

分享到:

栏目导航

推荐阅读

热门阅读