scr_export: Write the deliverables

View source: R/export.R

scr_exportR Documentation

Write the deliverables

Description

For an scr_result: the selection workbook (⁠selection_<target>.xlsx⁠: funnel, gains, screening, hold-out, models, votes, consensus, ledger, redundancy), the WOE SQL and the executive summary in Markdown. For an scr_scorecard: three workbooks, as separate files, plus the score SQL:

Usage

scr_export(x, dir, stamp = TRUE, ...)

## S3 method for class 'scr_capital'
scr_export(x, dir, stamp = TRUE, ...)

## S3 method for class 'scr_claims'
scr_export(x, dir, stamp = TRUE, ...)

## S3 method for class 'scr_classing'
scr_export(x, dir, stamp = TRUE, ...)

## S3 method for class 'scr_detection'
scr_export(x, dir, stamp = TRUE, ...)

## S3 method for class 'scr_ead'
scr_export(x, dir, stamp = TRUE, validation = NULL, tag = "ccf", ...)

## S3 method for class 'scr_result'
scr_export(x, dir, stamp = TRUE, ...)

## S3 method for class 'scr_scorecard'
scr_export(x, dir, stamp = TRUE, ...)

## S3 method for class 'scr_lgd'
scr_export(
  x,
  dir,
  stamp = TRUE,
  validation = NULL,
  elbe = NULL,
  tag = "model",
  ...
)

## S3 method for class 'scr_maturity'
scr_export(x, dir, stamp = TRUE, ...)

## S3 method for class 'scr_mix_shift'
scr_export(x, dir, stamp = TRUE, ...)

## S3 method for class 'scr_operating'
scr_export(x, dir, stamp = TRUE, ...)

## S3 method for class 'scr_overlap'
scr_export(x, dir, stamp = TRUE, ...)

## S3 method for class 'scr_pd'
scr_export(x, dir, stamp = TRUE, validation = NULL, ...)

## S3 method for class 'scr_rag'
scr_export(x, dir, stamp = TRUE, ...)

## S3 method for class 'scr_score_cross'
scr_export(x, dir, stamp = TRUE, ...)

## S3 method for class 'scr_segments'
scr_export(x, dir, stamp = TRUE, ...)

## S3 method for class 'scr_study'
scr_export(x, dir, stamp = TRUE, rag = NULL, ...)

## S3 method for class 'scr_uplift'
scr_export(x, dir, stamp = TRUE, ...)

Arguments

x

An object from scr_select(), scr_scorecard(), scr_coarse_classing(), scr_pd(), scr_lgd(), scr_ead(), scr_capital(), scr_bands(), scr_tiers(), scr_rag(), scr_claims(), scr_operating(), scr_score_cross(), scr_mix_shift(), scr_segments(), scr_maturity(), scr_uplift(), scr_overlap() or scr_detection().

dir

Output directory. Created if it does not exist.

stamp

If TRUE (default), writes to a timestamped subdirectory, preserving earlier runs.

...

For scr_scorecard: precomputed cutoff, strategy, reject and monitor objects, and revenue_good/loss_bad for the default strategy table.

validation

For the IRB models (scr_pd, scr_lgd, scr_ead): the matching validation object (scr_pd_validate(), scr_lgd_validate(), scr_ead_validate()); NULL runs it on the hold-out where possible.

tag

For scr_lgd and scr_ead: the file tag (⁠lgd_<tag>.xlsx⁠, ⁠ead_<tag>.xlsx⁠). scr_pd names its files after the target (⁠pd_<target>.xlsx⁠) and scr_capital after the framework (⁠capital_<framework>.xlsx⁠).

elbe

For scr_lgd: an scr_elbe() object; NULL computes it.

rag

For scr_study: an optional scr_rag() object whose lights are written to the same workbook.

Details

⁠scorecard_<target>.xlsx⁠

Score_Summary (with odds_orientation), Final_Scorecard, Coefficients, Sign_Check, Alignment, Alignment_Bands, Model_Card, Challenger and Swap_Set (when a challenger exists), Coarse_Classing and Decision_Ledger (after a lab commit).

⁠validation_<target>.xlsx⁠

Score_Gains_Frozen, Variable_Gains_IV, Discrimination_CI, Stability_PSI_Timeline, Stability_CSI_Timeline, Stability_Variables, Calibration, Calibration_Bands, Performance_By_Vintage, Rank_Order_Diagnostics.

⁠strategy_<target>.xlsx⁠

Population_Scope, Band_Coverage, Cutoff_Sweep, Strategy_Bands, Reject_Sensitivity, Monitoring_Plan.

For an scr_classing lab: one workbook (⁠classing_<target>.xlsx⁠) with the specification, the bins, the checks and the decision ledger. The IRB models write one workbook and one SQL file each (⁠pd_<target>.xlsx⁠, ⁠lgd_<tag>.xlsx⁠, ⁠ead_<tag>.xlsx⁠, ⁠capital_<framework>.xlsx⁠), with the validation, the ledger and the model card as sheets.

A score study (scr_bands(), scr_tiers()) writes one workbook, ⁠study_bands_<target>.xlsx⁠ or ⁠study_tiers_<target>.xlsx⁠, with its summary, its table, the cuts and the settings (plus the ledger and the stability of the tiers, and the lights of rag when given); a set of lights from scr_rag() writes ⁠rag_<target>.xlsx⁠; claims from scr_claims() write ⁠claims_<target>.xlsx⁠; an operating point from scr_operating() writes ⁠operating_<target>.xlsx⁠ (curve, optimum, constraints); two crossed scores from scr_score_cross() write ⁠score_cross_<score_a>_<score_b>.xlsx⁠ (cross table, overlap, overlap rates, association). The other score studies write one workbook each: ⁠mix_shift_<target>.xlsx⁠ from scr_mix_shift(), ⁠segments_<target>.xlsx⁠ from scr_segments(), ⁠maturity_<event>.xlsx⁠ from scr_maturity(), ⁠uplift_<target>.xlsx⁠ from scr_uplift(), ⁠overlap_<target>.xlsx⁠ from scr_overlap() and ⁠detection_<target>.xlsx⁠ from scr_detection().

The timeline and vintage sheets need the date column of the split; when it is absent they carry an availability row instead of a fabricated number.

Value

The object x, with ⁠$files⁠ filled, invisibly.

See Also

Other production: predict.scr_align(), scr_apply(), scr_monitor(), scr_monitoring_plan(), scr_reasons(), scr_sql()

Examples


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")
out <- file.path(tempdir(), "scorecraft-example")
res <- scr_export(res, out, stamp = FALSE)
basename(unlist(res$files))
sc <- scr_export(scr_scorecard(res), out, stamp = FALSE)
basename(unlist(sc$files))


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