reorder.rulelist {tidyrules}R Documentation

Reorder the rules/rows of a rulelist

Description

Implements a greedy strategy to add one rule at a time which maximizes/minimizes a metric.

Usage

## S3 method for class 'rulelist'
reorder(x, metric = "cumulative_coverage", minimize = FALSE, init = NULL, ...)

Arguments

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

See Also

rulelist, tidy, augment, predict, calculate, prune, reorder

Examples

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)


[Package tidyrules version 0.2.7 Index]