reorder.rulelist | R Documentation |
Implements a greedy strategy to add one rule at a time which maximizes/minimizes a metric.
## S3 method for class 'rulelist'
reorder(x, metric = "cumulative_coverage", minimize = FALSE, init = NULL, ...)
x |
A rulelist |
metric |
(character vector or named list) Name of metrics or a custom function(s). See calculate. The 'n+1'th metric is used when there is a match at 'nth' level, similar to base::order. If there is a match at final level, row order of the rulelist comes into play. |
minimize |
(logical vector) Whether to minimize. Either TRUE/FALSE or a logical vector of same length as metric |
init |
(positive integer) Initial number of rows after which reordering should begin |
... |
passed to calculate |
rulelist, tidy, augment, predict, calculate, prune, reorder
library("magrittr")
att = modeldata::attrition
tidy_c5 =
C50::C5.0(Attrition ~., data = att, rules = TRUE) %>%
tidy() %>%
set_validation_data(att, "Attrition") %>%
set_keys(NULL) %>%
head(5)
# with defaults
reorder(tidy_c5)
# use 'cumulative_overlap' to break ties (if any)
reorder(tidy_c5, metric = c("cumulative_coverage", "cumulative_overlap"))
# reorder after 2 rules
reorder(tidy_c5, init = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.