Learn R Programming

creditmodel (version 1.3.0)

get_ctree_rules: Parse desision tree rules

Description

get_ctree_rules This function is used to desision tree rules and percentage of 1 under each rule.

Usage

get_ctree_rules(
  tree_fit = NULL,
  train_dat = NULL,
  target = NULL,
  test_dat = NULL,
  tree_control = list(p = 0.05, cp = 0.0001, xval = 1, maxdepth = 10),
  seed = 46
)

Arguments

tree_fit

A tree model object.

train_dat

A data.frame of train.

target

The name of target variable.

test_dat

A data.frame of test.

tree_control

the list of parameters to control cutting initial breaks by decision tree.

seed

Random number seed. Default is 46.

Value

A data frame with tree rules and 1 percent under each rule.

See Also

rules_filter, check_rules

Examples

Run this code
# NOT RUN {
train_test = train_test_split(UCICreditCard, split_type = "Random", prop = 0.8, save_data = FALSE)
dat_train = train_test$train
dat_test = train_test$test
dat_train$default.payment.next.month = as.numeric(dat_train$default.payment.next.month)
get_ctree_rules(tree_fit = NULL, train_dat = dat_train[, 8:26],
target ="default.payment.next.month", test_dat = dat_test)

# }

Run the code above in your browser using DataLab