encode.woe | R Documentation |
encode.woe
implements replacement of character vector values with WoE values for a given mapping scheme.
This procedure is one of the helper functions which are handy for the model monitoring phase
(i.e. after model implementation).
encode.woe(x, mapping)
x |
Character vector to be re-coded. |
mapping |
Data frame with compulsory columns: |
The command encode.woe
returns vector of re-coded WoE values.
suppressMessages(library(PDtoolkit))
data(gcd)
mbin <- cum.bin(x = gcd$maturity, y = gcd$qual, sc.method = "together")
mbin[[1]]
table(mbin[[2]], useNA = "always")
gcd$x.mod <- mbin[[2]]
woe.rep <- replace.woe(db = gcd[, c("qual", "x.mod")], target = "qual")
gcd$x.woe <- woe.rep[[1]]$x
mapping <- data.frame(x.mod = gcd$x.mod, x.woe = gcd$x.woe)%>%
group_by(x.mod, x.woe) %>%
summarise(n = n(), .groups = "drop")
mapping <- data.frame(mapping[, -3])
ewoe <- encode.woe(x = gcd$x.mod, mapping = mapping)
identical(ewoe, woe.rep[[1]]$x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.