get_concensus_rules: Consolidates the rules in a decision tree per cluster

Description Usage Arguments Details Value Examples

View source: R/print_tree_rules.R

Description

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

Usage

1

Arguments

tree

partykit::ctree fit decision tree

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.

Value

a nested list

Examples

 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"

jspaezp/sctree documentation built on April 30, 2020, 10:36 p.m.