Learn R Programming

scorecard (version 0.1.5)

scorecard_ply: Application of Scorecard

Description

scorecard_ply calculates credit score using the results of scorecard.

Usage

scorecard_ply(dt, card, only_total_score = TRUE, print_step = 1L)

Arguments

dt

Original data

card

Scorecard generated from scorecard.

only_total_score

A logical value. Default is TRUE, which means only total credit score is return. Otherwise, if it is FALSE, which means both total credit score and score points of each variables are return.

print_step

A non-negative integer. Default is 1. Print variable names by print_step when print_step>0. If print_step=0, no message is printed.

Value

Credit score

See Also

scorecard

Examples

Run this code
# NOT RUN {
library(data.table)
library(scorecard)

# load germancredit data
data("germancredit")

# select only 5 x variables and rename creditability as y
dt = setDT(germancredit)[, c(1:5, 21)][, `:=`(
  y = ifelse(creditability == "bad", 1, 0),
  creditability = NULL
)]

# woe binning ------
bins = woebin(dt, "y")
dt_woe = woebin_ply(dt, bins)

# glm ------
m = glm( y ~ ., family = "binomial", data = dt_woe)
# summary(m)

# }
# NOT RUN {
# 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_woe$pred = predict(m, type='response', dt_woe)

# performace
# ks & roc plot
# perf_eva(dt_woe$y, dt_woe$pred)
# }
# NOT RUN {
# scorecard
# Example I # creat a scorecard
card = scorecard(bins, m)

# credit score
# Example I # only total score
score1 = scorecard_ply(dt, card)

# }
# NOT RUN {
# 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