| scr_apply | R Documentation |
Materializes in R exactly what the production SQL does: the frozen Stage
1 pre-processing (training median, special-population flags,
"MISSING") followed by the frozen Stage 2 binning and, for a scorecard,
by the points. Nothing is refitted. The two paths, R and SQL, produce the
same numbers, and a test guarantees it.
scr_apply(x, newdata, ...)
## S3 method for class 'scr_result'
scr_apply(
x,
newdata,
features = scr_selected(x),
what = c("woe", "bin", "both"),
...
)
## S3 method for class 'scr_scorecard'
scr_apply(x, newdata, what = c("score", "points", "woe", "all"), ...)
## S3 method for class 'scr_ead'
scr_apply(x, newdata, what = c("all", "ead", "pool"), ...)
## S3 method for class 'scr_lgd'
scr_apply(x, newdata, what = c("pool", "lgd", "all"), ...)
## S3 method for class 'scr_pd'
scr_apply(x, newdata, ...)
## S3 method for class 'scr_study'
scr_apply(x, newdata, score = "score", numbered = TRUE, ...)
x |
An object from |
newdata |
New table with the source columns of the requested variables. The target column is not needed. |
... |
Passed on to the methods. |
features |
For |
what |
For |
score |
For |
numbered |
For a tiers study: |
A data.table with one row per row of newdata.
For scr_result: <f>_woe and/or <f>_bin per variable. For
scr_scorecard, "score" gives link (logit), prob (model
probability), score (exact, a + b * logit) and score_points (base
plus the whole points per bin); "points" gives score, score_points
and <f>_points; "woe" gives link, score and <f>_woe; "all"
gives everything.
scr_pd returns score, score_points, grade, pd (calibrated
individual PD), pd_be and pd_final of the grade. scr_lgd returns
pool, lgd_lra, lgd_dt, lgd_final and, with what, p_cure,
severity and lgd_pred. scr_ead returns pool, measure,
utilisation, undrawn, ccf_applied, ead_model, ead_floor,
ead_predicted and ead_floor_binding; the predicted EAD is never below
the drawn amount. scr_capital() reads pd_final, lgd_final and
ead_predicted from these outputs in its list form.
For a score study (scr_bands(), scr_tiers()), newdata is returned
(as a copy) with tier, the band or tier number, and tier_label. The
intervals are left-closed: score >= cut is the upper side, and a
missing score gives a missing tier.
The labels of a tiers study carry their order, "01." for the tier with
the highest event rate (the first row of the tiers table) down to the
tier with the lowest, so they sort from the event-richest tier under any
objective and direction; tier is unchanged and still rises with the
event rate. The result joins to the tier_label column of the tiers
table. numbered = FALSE returns the plain labels (its label column).
Other production:
predict.scr_align(),
scr_export(),
scr_monitor(),
scr_monitoring_plan(),
scr_reasons(),
scr_sql()
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")
new <- head(scr_demo, 50)
str(scr_apply(res, new)[, 1:3])
sc <- scr_scorecard(res)
head(scr_apply(sc, new))
head(scr_apply(sc, new, what = "points"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.