tidyRules.rpart: Obtain rules as a tidy tibble from a rpart model

Description Usage Arguments Details Value Author(s) Examples

View source: R/rpart.R

Description

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

Usage

1
2
## S3 method for class 'rpart'
tidyRules(object, ...)

Arguments

object

Fitted model object with rules

...

Other arguments (currently unused)

Details

NOTE: For rpart rules, one should build the model without ordered factor variable. We recommend you to convert ordered factor to factor or integer class.

Optional named arguments:

Value

A tibble where each row corresponds to a rule. The columns are: support, confidence, lift, LHS, RHS

Author(s)

Amith Kumar U R, amith54@gmail.com

Examples

1
2
iris_rpart <- rpart::rpart(Species ~ .,data = iris)
tidyRules(iris_rpart)

Example output

# A tibble: 3 x 6
     id LHS                                   RHS       support confidence  lift
  <int> <chr>                                 <chr>       <int>      <dbl> <dbl>
1     1 Petal.Length < 2.45                   setosa         50      0.981  2.94
2     2 Petal.Length >= 2.45 & Petal.Width <versicol54      0.893  2.68
3     3 Petal.Length >= 2.45 & Petal.Width >virginica      46      0.958  2.88

tidyrules documentation built on July 1, 2020, 5:49 p.m.