scorecraft-package: scorecraft: scorecard engine with alignment, cut-off...

scorecraft-packageR Documentation

scorecraft: scorecard engine with alignment, cut-off strategy, IRB risk parameters and production SQL

Description

A professional scorecard is born of eight chained stages, numbered 0 to 7 in every message and in scr_config_keys(), and this package exposes each of them as a function of its own, next to the shortcut scr_select() that chains them for the common case:

Details

  1. Split (scr_split()): train/hold-out by whole periods (out-of-time) before any supervised fit.

  2. Triage (scr_triage()): structural filters, decomposition of sentinels and missing values, exact duplicates. The data leaves with no NA.

  3. Binning and screening (scr_bin()): optimal bins parallelized by column, eight admission rules, hold-out revalidation with frozen bins, redundancy pruning.

  4. Multi-strategy selection (scr_model()): elastic net, boosting and random forest on the WOE space; consensus weighted by hold-out Gini.

  5. Scorecard (scr_scorecard()): logistic regression on the shortlist, sign check, points per bin, a tree challenger explicitly without points.

  6. Alignment (scr_align()): log-odds regression on the raw score composed with the PDO map, with odds_orientation recorded. Runs automatically inside scr_scorecard().

  7. Cut-off and strategy (scr_cutoff(), scr_strategy(), scr_reject()): sweep with frozen cuts, bands with marginal expected profit, honest reject inference through a sensitivity band.

The deliverables (scr_export()) are the audit funnel, the gains tables, the production SQL (scr_sql()) with R-SQL equivalence verified by test, and four .xlsx workbooks. scr_monitor() recomputes PSI/CSI on new data, with both the fixed and the sample-size-adjusted threshold, and never schedules anything by itself.

IRB risk parameters

The IRB (internal ratings-based) layer, stages 8 to 12 of scr_config_keys(), turns the scorecard into regulatory parameters and keeps the same contracts (one configuration, ledgers, hold-out revalidation, workbooks, production SQL). scr_irb_params() holds every regime-specific number as a table selected by preset ("bcb", "basel3_final", "crr3"); scr_default() builds the default flag from a monthly panel and scr_default_rate() the default rates by cohort with the long-run average. PD: scr_calibrate() anchors the scorecard to a central tendency, scr_grades() cuts the score into rating grades, scr_moc() and scr_pd() add the margin of conservatism and the floor, and scr_pd_validate() runs the calibration, discrimination and stability tests with traffic lights; scr_master_scale(), scr_migration() and scr_pd_pit_ttc() support the grade structure, the migration analysis and the point-in-time bridge. LGD: scr_workout() discounts recovery cash flows into realized LGD, scr_lgd() fits the cure and severity stages and the pools, scr_lgd_downturn(), scr_lgd_floor() and scr_elbe() complete the estimate, scr_lgd_pools() and scr_lgd_validate() close the pools and the validation. EAD: scr_ead_data() builds the realized conversion factors from facility snapshots and scr_ead() the pools; scr_ead_downturn() and scr_ead_validate() add the downturn and the validation. scr_el(), scr_irb_rw(), scr_sa_rw(), scr_capital(), scr_pd_stress() and scr_ecl() compute expected loss, risk weights, capital and expected credit loss. Binning against a continuous target goes through scr_bin_continuous(), whose result the engine reproduces in R and in SQL. The regulatory texts behind the presets are listed in scr_irb_params(); users are responsible for checking the tables against the texts in force before any regulatory use.

Score studies

The score studies, stage 13 of scr_config_keys(), read a score against its outcome from one table of counts per score value: scr_bands() (percentile and tail bands frozen on the reference), scr_tiers() (a few labeled tiers), scr_rag() (red, amber and green lights against the reference), scr_claims() (tested statements about event rates), scr_operating() (the cut under volume, budget and capacity constraints) and scr_score_cross() (two scores on the same rows). Six more read the score against a second dimension: scr_mix_shift() (a change of the event rate split into mix and rate effects), scr_segments() (one score on many segments), scr_maturity() (events over time by band, with censoring), scr_uplift() (a treated against a control group), scr_overlap() (rules against the alerts of a score) and scr_detection() (time to detection of fraud episodes).

Parallelism

Column-wise work (binning, hold-out revalidation, CSI) and the bootstrap run on config$nthread workers. The backend follows getOption("scorecraft.parallel"): "fork" on unix by default, "psock" on Windows (and selectable anywhere, e.g. for tests), "serial" to switch parallelism off. Results are identical across backends.

Forked workers are clones of the parent and, because the garbage collector writes to the objects it marks, each one ends up owning a copy of most of the parent heap. On Linux the number of fork workers is therefore capped at getOption("scorecraft.fork_mem_fraction", 0.75) of the memory available divided by the resident size of the session, with a message when the cap applies. Set the option to Inf to disable it.

Reading conventions

objective declares the vocabulary and the direction of the scale ("risk": more points, safer; "propensity": more points, more likely) and does not change what is modeled. event_level changes what is modeled. Both are documented in scr_config() and scr_split().

Author(s)

Maintainer: Jose Evandeilton Lopes evandeilton@gmail.com [copyright holder]

Authors:

See Also

Useful links:


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