| scr_split | R Documentation |
First stage of the pipeline, callable on its own. Converts the target to
0/1 (resolving event_level), types the candidates (numerics become
double, everything else becomes character) and splits train and
hold-out before any supervised fit.
scr_split(
data,
target,
date_col = NULL,
ratio = 0.3,
seed = NULL,
event_level = NULL,
drop = character(),
copy = TRUE
)
data |
A |
target |
Name of the target column. Binary: 0/1, logical, or a two-level factor/character. |
date_col |
Date column of the out-of-time cut. |
ratio |
Target hold-out fraction. |
seed |
Seed of the random split. |
event_level |
Which target value counts as the event. |
drop |
Columns that are never candidates (identifiers, sibling
targets, free text). They stay in the funnel as |
copy |
If |
The split prefers out-of-time by date_col: it is the only one that
tests generalization to a future period. The cut is made on the
distinct date values, not by row quantile: it picks the smallest set
of most recent periods that already reaches ratio of the population.
Without a date column, or with a single period, it falls back to random
stratified by the target. The date column is never a candidate: it is the
key of the split and leaves the contest. A text date column is read as an
ISO date (YYYY-MM-DD, YYYY/MM/DD, YYYY-MM) or as all-digit periods
(YYYYMM); rows with a missing date belong to no period and are left out
of both train and hold-out, with a warning in the log.
An scr_split object with data (typed), target, train_idx,
holdout_idx, method, cutoff, date_col and cols (features,
var_num, var_cat, dropped, event).
event_level changes what is modeled. Passing 0 makes class 0 the
event: the sign of every WOE flips, the emitted SQL changes, the points
change. For a text target, the second level in alphabetical order is the
event by default, and the choice is always reported. Not to be confused
with config$objective, which only orients the reading and the points
scale.
Other stages:
scr_align(),
scr_bin(),
scr_cutoff(),
scr_model(),
scr_reject(),
scr_scorecard(),
scr_select(),
scr_strategy(),
scr_triage()
sp <- scr_split(scr_demo, "default", date_col = "ref_date", drop = "id")
sp
length(sp$train_idx); length(sp$holdout_idx)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.