# NOT RUN {
# load germancredit data
data("germancredit")
# filter variable via missing rate, iv, identical value rate
dt_sel = var_filter(germancredit, "creditability")
# woe binning ------
bins = woebin(dt_sel, "creditability")
dt_woe = woebin_ply(dt_sel, bins)
# glm ------
m = glm(creditability ~ ., family = binomial(), data = dt_woe)
# summary(m)
# Select a formula-based model by AIC
m_step = step(m, direction="both", trace=FALSE)
m = eval(m_step$call)
# summary(m)
# predicted proability
# dt_pred = predict(m, type='response', dt_woe)
# performace
# ks & roc plot
# perf_eva(dt_woe$creditability, dt_pred)
# scorecard
# Example I # creat a scorecard
card = scorecard(bins, m)
# credit score
# Example I # only total score
score1 = scorecard_ply(dt, card)
# Example II # credit score for both total and each variable
score2 = scorecard_ply(dt, card, only_total_score = F)
# }
Run the code above in your browser using DataLab