Returns a nested list of the concensus rules to define a cluster, given a partykit decision tree.

get_concensus_rules(tree)

Arguments

tree

partykit::ctree fit decision tree

Value

a nested list

Details

level 1 of the nested list is the group being predicted. level 2 is either "all" or "majority". each element is a character vector.

Examples

iris_tree <- partykit::ctree(Species ~ ., data = iris) str(get_concensus_rules(iris_tree))
#> List of 3 #> $ setosa :List of 2 #> ..$ all : chr "Petal.Length <= 1.9" #> ..$ majority: chr(0) #> $ versicolor:List of 2 #> ..$ all : chr [1:2] "Petal.Length > 1.9" "Petal.Width <= 1.7" #> ..$ majority: chr "Petal.Length <= 4.8" #> $ virginica :List of 2 #> ..$ all : chr [1:2] "Petal.Length > 1.9" "Petal.Width > 1.7" #> ..$ majority: chr(0) #> - attr(*, "class")= chr [1:2] "list" "concensus.rules"
# List of 3 # $ setosa :List of 2 # ..$ all : chr "Petal.Length <= 1.9" # ..$ majority: chr(0) # $ versicolor:List of 2 # ..$ all : chr [1:2] "Petal.Length > 1.9" "Petal.Width <= 1.7" # ..$ majority: chr "Petal.Length <= 4.8" # $ virginica :List of 2 # ..$ all : chr [1:2] "Petal.Length > 1.9" "Petal.Width > 1.7" # ..$ majority: chr(0) # - attr(*, "class")= chr [1:2] "list" "concensus.rules"