Each row corresponds to a rule
# S3 method for constparty
tidy(x, ...)
partykit::party model typically built using partykit::ctree
Other arguments (currently unused)
A rulelist object
These types of party models are supported:
regression
(y is numeric), classification
(y is factor)
For party classification model:
Output columns are: rule_nbr
, LHS
, RHS
, support
, confidence
, lift
, terminal_node_id
.
Rules are sorted in this order: desc(confidence)
, desc(lift)
,
desc(support)
.
For party regression model:
Output columns are: rule_nbr
, LHS
, RHS
, support
, IQR
, RMSE
, terminal_node_id
.
Rules are sorted in this order: RMSE
, desc(support)
.
pen = palmerpenguins::penguins
model_class_party = partykit::ctree(species ~ ., data = pen)
tidy(model_class_party)
#> ---- Rulelist --------------------------------
#> ▶ Keys: NULL
#> ▶ Number of rules: 6
#> ▶ Model type: constparty
#> ▶ Estimation type: classification
#> ▶ Is validation data set: FALSE
#>
#>
#> rule_nbr LHS RHS support confidence lift terminal_node_id
#> <int> <chr> <fct> <dbl> <dbl> <dbl> <chr>
#> 1 1 ( island %in% c('Bis… Gent… 123 1 2.77 6
#> 2 2 ( island %in% c('Bis… Adel… 38 1 2.26 4
#> 3 3 ( island %in% c('Dre… Adel… 100 0.99 2.24 9
#> 4 4 ( island %in% c('Dre… Chin… 64 0.969 4.90 11
#> 5 5 ( island %in% c('Bis… Adel… 7 0.857 1.94 5
#> 6 6 ( island %in% c('Dre… Adel… 12 0.583 1.32 10
#> ----------------------------------------------
model_regr_party = partykit::ctree(bill_length_mm ~ ., data = pen)
tidy(model_regr_party)
#> ---- Rulelist --------------------------------
#> ▶ Keys: NULL
#> ▶ Number of rules: 9
#> ▶ Model type: constparty
#> ▶ Estimation type: regression
#> ▶ Is validation data set: FALSE
#>
#>
#> rule_nbr LHS RHS support IQR RMSE terminal_node_id
#> <int> <chr> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 1 ( species %in% c('Chinstr… 48.3 8 1.03 0.884 15
#> 2 2 ( species %in% c('Adelie'… 39.4 30 2.18 1.38 5
#> 3 3 ( species %in% c('Chinstr… 50.2 28 1.28 1.88 16
#> 4 4 ( species %in% c('Chinstr… 47.4 19 2.80 1.97 13
#> 5 5 ( species %in% c('Adelie'… 37.2 78 2.80 2.00 3
#> 6 6 ( species %in% c('Chinstr… 45.5 77 3.1 2.08 9
#> 7 7 ( species %in% c('Chinstr… 51.3 43 1.95 2.31 17
#> 8 8 ( species %in% c('Adelie'… 41.1 44 2.47 2.48 6
#> 9 9 ( species %in% c('Chinstr… 47.7 17 4.1 3.27 10
#> ----------------------------------------------