# NOT RUN {
# load germancredit data
data(germancredit)
# Example I
# binning of two variables in germancredit dataset
# using tree method
bins2_tree = woebin(germancredit, y="creditability",
x=c("credit.amount","housing"), method="tree")
bins2_tree
# }
# NOT RUN {
# using chimerge method
bins2_chi = woebin(germancredit, y="creditability",
x=c("credit.amount","housing"), method="chimerge")
# Example II
# binning of the germancredit dataset
bins_germ = woebin(germancredit, y = "creditability")
# converting bins_germ into a dataframe
# bins_germ_df = data.table::rbindlist(bins_germ)
# Example III
# customizing the breakpoints of binning
library(data.table)
dat = rbind(
germancredit,
data.table(creditability=sample(c("good","bad"),10,replace=TRUE)),
fill=TRUE)
breaks_list = list(
age.in.years = c(26, 35, 37, "Inf%,%missing"),
housing = c("own", "for free%,%rent")
)
special_values = list(
credit.amount = c(2600, 9960, "6850%,%missing"),
purpose = c("education", "others%,%missing")
)
bins_cus_brk = woebin(dat, y="creditability",
x=c("age.in.years","credit.amount","housing","purpose"),
breaks_list=breaks_list, special_values=special_values)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab