| scr_scorecard | R Documentation |
Fits a logistic regression on the WOE columns of the shortlist, checks
the sign of the coefficients, aligns the logit to the declared scale with
scr_align() (always) and distributes the points per bin. Measures the
score on train and hold-out with a bootstrap CI (always), builds the
gains with bands frozen on train, the score PSI and the CSI per
variable (fixed and n-adjusted thresholds), the
calibration and the rank-order diagnostics (a one-sided Fisher exact
test of each band against the previous, riskier one). Optionally fits a
tree challenger on the same WOE columns, aligned to the same scale, with an
explicit supports_scorecard = FALSE: it compares, it never
produces points or reason codes.
scr_scorecard(
x,
features = NULL,
base_score = NULL,
base_odds = NULL,
pdo = NULL,
direction = NULL,
align_method = NULL,
challenger = NULL,
points_style = NULL,
n_boot = NULL,
seed = NULL
)
x |
An object from |
features |
Variables of the scorecard. Defaults to |
base_score, base_odds, pdo, direction |
The scale; |
align_method |
|
challenger |
|
points_style |
|
n_boot |
CI resamples; |
seed |
Seed; |
An scr_scorecard object. Main components: features, coef,
sign_check, alignment (an scr_align object), points,
base_points, samples (train and hold-out: link, prob, score,
score_points, y, date), metrics, gains, stability (score
and variables), calibration, rank_order, challenger,
model_card and sql. Also scale (base_score, base_odds, pdo,
factor, offset, direction, odds_orientation), breaks (the
score bands frozen on train), monitoring_plan (see
scr_monitoring_plan()), holdout_bins, fit and ledger (the frozen
binning and pre-processing that scr_apply() and scr_sql()
reproduce) and, after a lab commit, decisions and provenance.
The engine's WOE is event-oriented, so every glm coefficient must be
positive. A variable with a non-positive coefficient (or above
max_abs_coef in absolute value) is explaining what another already
explained, with the sign reversed; it is removed and the model refitted,
one at a time, the most negative first, and each removal is recorded in
sign_check. The last remaining variable is never removed: it is kept
and flagged NON_POSITIVE_COEF_KEPT_LAST.
The final shortlist of the scorecard (features) is what scr_sql()
covers.
With score = a + b * logit and logit = alpha + sum(beta_j * woe_ij):
\mathrm{points}_{ij} = b\,\beta_j\,\mathrm{woe}_{ij},\qquad
\mathrm{base} = a + b\,\alpha.
points_style = "distributed" spreads base / k over each
characteristic (Siddiqi, 2006, chapter 6), leaving base_points = 0. The
exact points stay in points_raw; points is the rounded version when
points_round = TRUE. The exact score (score) and the whole-points
score (score_points) are both returned by scr_apply() and both
emitted by scr_sql(). A row that falls in no fitted bin (a category
never seen on train, a missing value without a missing bin) gets a WOE of
0 from the binning engine, hence the points of a WOE of 0: 0, or
base / k under "distributed".
Other stages:
scr_align(),
scr_bin(),
scr_cutoff(),
scr_model(),
scr_reject(),
scr_select(),
scr_split(),
scr_strategy(),
scr_triage()
cfg <- scr_config(verbose = FALSE, nthread = 1, use_ranger = FALSE,
xgb_rounds = 60, n_boot = 20)
res <- scr_select(scr_demo, "default", config = cfg, drop = "id",
date_col = "ref_date")
sc <- scr_scorecard(res)
sc
head(sc$points[, c("variable", "bin", "woe", "points")])
sc$metrics
sc$alignment
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.