scr_bin: Stage 2: optimal binning, screening, hold-out revalidation...

View source: R/bin.R

scr_binR Documentation

Stage 2: optimal binning, screening, hold-out revalidation and pruning

Description

Fits the bins on the training rows only (cut points and WOE use the target), in parallel by column, and applies in sequence:

Usage

scr_bin(triage, config = scr_config())

Arguments

triage

An object from scr_triage().

config

An object from scr_config().

Details

  1. Screening, native to the engine: eight admission rules (IV_BELOW_MIN, IV_SUSPICIOUS, NOT_MONOTONIC, TOO_FEW_BINS, TOO_MANY_BINS, SMALL_BIN, DEGENERATE_BIN, BINNING_ERROR).

  2. Hold-out revalidation with frozen bins: IV recomputed on the same labels, train/hold-out PSI (the fixed threshold decides; the n-adjusted one is reported) and the fraction of hold-out without a bin.

  3. Redundancy pruning by rank correlation on the WOE space, ranked by hold-out IV. Under allow_derived_final = FALSE the derived flags leave before this step (derived_excluded), so that a flag that cannot be delivered never prunes a real column.

Value

An scr_bins object with fit (an obwoe object), screen (summary and full), holdout, prune, pool (eligible for the models), derived_excluded, the counts binned, pos_screen and pos_holdout (the survivors of each gate, in order), the WOE matrices woe_train/woe_holdout, the originating triage and the config.

Parallelism

Columns are split into config$nthread chunks, each chunk is binned by a worker and the fits are merged. The result is identical to the serial one (a test pins this): the engine is deterministic per column.

See Also

Other stages: scr_align(), scr_cutoff(), scr_model(), scr_reject(), scr_scorecard(), scr_select(), scr_split(), scr_strategy(), scr_triage()

Examples

cfg <- scr_config(verbose = FALSE, nthread = 1)
sp <- scr_split(scr_demo, "default", date_col = "ref_date", drop = "id")
bn <- scr_bin(scr_triage(sp, cfg), cfg)
bn
head(bn$holdout)

scorecraft documentation built on Dec. 6, 2026, 1:09 a.m.