scorecard2
creates a scorecard based on the results from woebin
. It has the same function of scorecard
, but without model object input and provided adjustment for oversampling.
scorecard2(bins, dt, y, x = NULL, points0 = 600, odds0 = 1/19,
pdo = 50, basepoints_eq0 = FALSE, digits = 0, return_prob = FALSE,
posprob_pop = NULL, posprob_sample = NULL, positive = "bad|1", ...)
Binning information generated from woebin
function.
A data frame with both x (predictor/feature) and y (response/label) variables.
Name of y variable.
Name of x variables. If it is NULL, then all variables in bins are used. Defaults to NULL.
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.
Logical, defaults to FALSE. If it is TRUE, the predict probability will also return.
Positive probability of population. Accepted range: 0-1, default to NULL. If it is not NULL, the model will adjust for oversampling.
Positive probability of sample. Accepted range: 0-1, default to the positive probability of the input dt.
Value of positive class, default "bad|1".
Additional parameters.
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
# train only
## create scorecard
card1 = scorecard2(bins=bins, dt=dtlst$train, y='creditability')
## scorecard and predicted probability
cardprob1 = scorecard2(bins=bins, dt=dtlst$train, y='creditability', return_prob = TRUE)
# both train and test
## create scorecard
card2 = scorecard2(bins=bins, dt=dtlst, y='creditability')
## scorecard and predicted probability
cardprob2 = scorecard2(bins=bins, dt=dtlst, y='creditability', return_prob = TRUE)
# }