Each row corresponds to a rule. A rule can be copied into `dplyr::filter` to filter the observations corresponding to a rule

# S3 method for cubist
tidyRules(object, ...)

Arguments

object

Fitted model object with rules

...

Other arguments (currently unused)

Value

A tibble where each row corresponds to a rule. The columns are: support, mean, min, max, error, lhs, rhs and committee

Details

When col_classes argument is missing, an educated guess is made about class by parsing the RHS of sub-rule. This might sometimes not lead to a parsable rule.

Optional named arguments:

  • language (string, default: "r"): language where the rules are parsable. The allowed options is one among: r, python, sql

Examples

data("attrition", package = "modeldata") attrition <- tibble::as_tibble(attrition) cols_att <- setdiff(colnames(attrition), c("MonthlyIncome", "Attrition")) cb_att <- Cubist::cubist(x = attrition[, cols_att],y = attrition[["MonthlyIncome"]]) tr_att <- tidyRules(cb_att) tr_att
#> # A tibble: 8 x 9 #> id LHS RHS support mean min max error committee #> <int> <chr> <chr> <int> <dbl> <dbl> <dbl> <dbl> <int> #> 1 1 JobLevel <= 1 (2265) + (35 … 543 2787. 1009 4968 559. 1 #> 2 2 JobLevel > 1 … (-2092) + (32… 57 4459 2272 5301 328. 1 #> 3 3 JobLevel > 1 … (-39) + (2333… 124 4672. 2042 9724 1013. 1 #> 4 4 JobLevel > 1 … (1859) + (260… 387 6261. 2176 9998 995. 1 #> 5 5 JobRole %in% … (-1136) + (35… 245 8469. 2592 13973 932. 1 #> 6 6 JobRole %in% … (-1384.7) + (… 26 12857. 11031 17603 517. 1 #> 7 7 JobLevel <= 4… (4166.4) + (3… 87 15824 12061 17924 694. 1 #> 8 8 JobLevel > 4 (13633) + (10… 69 19192. 18041 19999 416 1