| scr_bin_continuous | R Documentation |
Supervised binning for a bounded continuous target, with the result in
the shape of an obwoe object, so that the scr_apply() and scr_sql()
machinery (OptimalBinningWoE::obwoe_apply() and
OptimalBinningWoE::obwoe_sql()) reproduces the bin statistic unchanged.
The woe slot of every bin carries the target mean of the bin (or its
logit with scale = "logit"); iv carries the bin's share of the
between-bin sum of squares, so total_iv is the eta-squared of the
driver, in [0, 1].
scr_bin_continuous(
data,
target,
features,
train_idx = NULL,
holdout_idx = NULL,
min_bins = 2L,
max_bins = 6L,
min_share = 0.05,
min_n = 30L,
monotone = c("auto", "increasing", "decreasing", "none"),
scale = c("mean", "logit"),
nthread = 1L,
alpha = 0.05
)
data |
A |
target |
Column name of the continuous target. |
features |
Column names of the drivers. |
train_idx, holdout_idx |
Row indices; |
min_bins, max_bins |
Target range of bins per driver. |
min_share |
Minimum share of training rows per bin. |
min_n |
Minimum number of training rows per bin. |
monotone |
|
scale |
|
nthread |
Parallel workers by driver, through the package backend. |
alpha |
Alpha of the PSI critical value in the revalidation. |
Numeric drivers must not contain missing values: run scr_triage() (or
impute) first, exactly as the scorecard pipeline does. Categorical
missing values become the level "NA", as in the engine. When a
holdout_idx is given, the frozen bins are revalidated: the hold-out
bin means are recomputed, the PSI of the bin shares is reported with the
sample-size-adjusted critical value, a driver whose hold-out means
break the training order is flagged UNSTABLE_HOLDOUT, one whose bin
shares shift (fixed PSI flag "shift", PSI at or above 0.25) is flagged
PSI_ACTION, and one with more than 1% of hold-out rows outside the
bins UNBINNED_HOLDOUT.
An object of class scr_cbins: fit (the obwoe-shaped
object), summary (one row per driver: feature, type, n_bins,
eta2, direction, converged, and after revalidation eta2_holdout,
psi, psi_flag, holdout_ok, holdout_reason), holdout (bin
table per driver with train and hold-out means), scale and target.
summary keeps the engine columns (algorithm, total_iv,
iterations, error) and, after revalidation, psi_critical,
psi_flag_adjusted and pct_unbinned.
Other irb-ead:
scr_ead(),
scr_ead_data(),
scr_ead_downturn(),
scr_ead_validate()
set.seed(1)
d <- data.frame(x = runif(600), g = sample(c("a", "b", "c", "d"), 600, TRUE))
d$y <- pmin(1, pmax(0, 0.2 + 0.6 * d$x + (d$g == "d") * 0.2 + rnorm(600, 0, 0.1)))
cb <- scr_bin_continuous(d, "y", c("x", "g"), train_idx = 1:400, holdout_idx = 401:600)
cb
cb$fit$results$x$bin
cb$fit$results$x$woe # bin means of y
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.