Description Usage Arguments Details Value Examples
View source: R/print_tree_rules.R
Returns a nested list of the concensus rules to define a cluster, given a partykit decision tree.
1 | get_concensus_rules(tree)
|
tree |
partykit::ctree fit decision tree |
level 1 of the nested list is the group being predicted. level 2 is either "all" or "majority". each element is a character vector.
a nested list
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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"
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.