woe_trans_all {creditmodel}R Documentation

WOE Transformation

Description

woe_trans is for transforming data to woe. The woe_trans_all function is a simpler wrapper for woe_trans.

Usage

woe_trans_all(
  dat,
  x_list = NULL,
  ex_cols = NULL,
  bins_table = NULL,
  target = NULL,
  breaks_list = NULL,
  note = FALSE,
  save_data = FALSE,
  parallel = FALSE,
  woe_name = FALSE,
  file_name = NULL,
  dir_path = tempdir(),
  ...
)

woe_trans(
  dat,
  x,
  bins_table = NULL,
  target = NULL,
  breaks_list = NULL,
  woe_name = FALSE
)

Arguments

dat

A data.frame with independent variables.

x_list

A list of x variables.

ex_cols

Names of excluded variables. Regular expressions can also be used to match variable names. Default is NULL.

bins_table

A table contians woe of each bin of variables, it is generated by codeget_bins_table_all,codeget_bins_table

target

The name of target variable. Default is NULL.

breaks_list

A list contains breaks of variables. it is generated by codeget_breaks_all,codeget_breaks

note

Logical, outputs info. Default is TRUE.

save_data

Logical, save results in locally specified folder. Default is TRUE

parallel

Logical, parallel computing. Default is FALSE.

woe_name

Logical. Add "_woe" at the end of the variable name.

file_name

The name for periodically saved woe file. Default is "dat_woe".

dir_path

The path for periodically saved woe file Default is "./data"

...

Additional parameters.

x

The name of an independent variable.

Value

A list of breaks for each variables.

See Also

get_tree_breaks, cut_equal, select_best_class, select_best_breaks

Examples

sub = cv_split(UCICreditCard, k = 30)[[1]]
dat = UCICreditCard[sub,]
dat = re_name(dat, "default.payment.next.month", "target")
dat = data_cleansing(dat, target = "target", obs_id = "ID", occur_time = "apply_date",
miss_values =  list("", -1))

train_test = train_test_split(dat, split_type = "OOT", prop = 0.7,
                                occur_time = "apply_date")
dat_train = train_test$train
dat_test = train_test$test
#get breaks of all predictive variables
x_list = c("PAY_0", "LIMIT_BAL", "PAY_AMT5", "EDUCATION", "PAY_3", "PAY_2")
breaks_list = get_breaks_all(dat = dat_train, target = "target",
                              x_list = x_list, occur_time = "apply_date", ex_cols = "ID",
save_data = FALSE, note  = FALSE)
#woe transform
train_woe = woe_trans_all(dat = dat_train,
                          target = "target",
                          breaks_list = breaks_list,
                          woe_name = FALSE)
test_woe = woe_trans_all(dat = dat_test,
                       target = "target",
                         breaks_list = breaks_list,
                         note = FALSE)


[Package creditmodel version 1.3.0 Index]