scr_select: Select variables for the scorecard

View source: R/select.R

scr_selectR Documentation

Select variables for the scorecard

Description

Shortcut that chains scr_split(), scr_triage(), scr_bin() and scr_model() on a table and a binary target, and returns an object with the shortlist, the complete audit funnel, the gains table and the production SQL of the approved variables. Every stage remains callable on its own for whoever wants more control (hybrid interface).

Usage

scr_select(
  data,
  target,
  config = scr_config(),
  drop = character(),
  date_col = config$oot_date_col,
  event_level = NULL,
  export = NULL,
  copy = TRUE
)

Arguments

data

A data.frame or data.table with the target, the candidates and, if any, the date column of the out-of-time cut.

target

Name of the target column (0/1, logical, or a two-level factor/character).

config

An object from scr_config().

drop

Columns that are never candidates. They stay in the funnel as ⁠00.config⁠.

date_col

Date column of the out-of-time cut. Defaults to config$oot_date_col.

event_level

Which target value counts as the event; see scr_split().

export

Directory to write the deliverables to. NULL (default) writes nothing; use scr_export() later.

copy

If TRUE (default), works on a copy of data.

Value

An object of class scr_result. Read it with scr_selected(), scr_funnel(), scr_gains(), scr_sql(), scr_leakage() and summary(); continue with scr_scorecard(); write it with scr_export().

Reproducibility

With the same data, the same target and the same config$seed, the result is identical with one or several nthread: the seed governs the random split, the cross-validation, the classifier subsample, the trees and the bootstrap, and the binning is deterministic per column.

See Also

scr_run() for several targets straight from the database, scr_scorecard() for the next step.

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

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")
res
scr_selected(res)
head(scr_funnel(res, only_selected = TRUE))

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