scorecard_ply
calculates credit score using the results from scorecard
.
scorecard_ply(dt, card, only_total_score = TRUE, print_step = 0L,
replace_blank_na = TRUE, var_kp = NULL)
A data frame, which is the original dataset for training model.
A data frame or a list of data frames. It's the scorecard generated from the function scorecard
.
Logical, Defaults to TRUE. If it is TRUE, then the output includes only total credit score; Otherwise, if it is FALSE, the output includes both total and each variable's credit score.
A non-negative integer. Defaults to 1. If print_step>0, print variable names by each print_step-th iteration. If print_step=0, no message is print.
Logical. Replace blank values with NA. Defaults to TRUE. This argument should be the same with woebin
's.
Name of force kept variables, such as id column. Defaults to NULL.
A data frame in score values
# \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
# scorecard
card = scorecard2(bins=bins, dt=dtlst$train, y='creditability')
# credit score
# Example I # only total score
score1 = scorecard_ply(germancredit, card)
# Example II # credit score for both total and each variable
score2 = scorecard_ply(germancredit, card, only_total_score = FALSE)
# }