scorecard
creates a scorecard based on the results from woebin
and glm
.
scorecard(bins, model, points0 = 600, odds0 = 1/19, pdo = 50,
basepoints_eq0 = FALSE, digits = 0)
Binning information generated from woebin
function.
A glm model object.
Target points, default 600.
Target odds, default 1/19. Odds = p/(1-p).
Points to Double the Odds, default 50.
Logical, Defaults to FALSE. If it is TRUE, the basepoints will equally distribute to each variable.
The number of digits after the decimal point for points calculation. Default 0.
A list of scorecard data frames
# \donttest{
# load germancredit data
data("germancredit")
# filter variable via missing rate, iv, identical value rate
dtvf = var_filter(germancredit, "creditability")
#> ℹ Filtering variables via missing_rate, identical_rate, info_value ...
#> ✔ 1 variables are removed via identical_rate
#> ✔ 6 variables are removed via info_value
#> ✔ Variable filtering on 1000 rows and 20 columns in 00:00:00
#> ✔ 7 variables are removed in total
# split into train and test
dtlst = split_df(dtvf, y = 'creditability')
# binning
bins = woebin(dtlst$train, "creditability")
#> ℹ Creating woe binning ...
#> ✔ Binning on 681 rows and 14 columns in 00:00:00
# to woe
dtlst_woe = lapply(dtlst, function(d) woebin_ply(d, bins))
#> ℹ Converting into woe values ...
#> ✔ Woe transformating on 681 rows and 13 columns in 00:00:00
#> ℹ Converting into woe values ...
#> ✔ Woe transformating on 319 rows and 13 columns in 00:00:00
# lr
m = glm(creditability ~ ., family = binomial(), data = dtlst_woe$train)
# scorecard
card = scorecard(bins, m)
prob = predict(m, dtlst_woe$train, type='response')
# problst = lapply(dtlst_woe, function(x) predict(m, x, type='response'))
# }