R/get_split_names.R

Defines functions get_split_names

Documented in get_split_names

#' Method for extracting names of splitting features used in a tree.
#'
#' @param tree a tree object.
#' @param data train or test set.
#' @import pre
#' @return names of splitting features extracted from tree object.
get_split_names = function(tree,data){

  # path: the string that contains all the node information
  paths <- eval(parse(text = "pre:::list.rules(tree, removecomplements = FALSE)"))
  vnames = names(data)
  split_names = vnames[sapply(sapply(vnames, FUN = function(var) grep(paste(paste(var,"<="),"|",paste(var,">"),sep=""), paths)), length) > 0]
  return (split_names)
}

Try the FREEtree package in your browser

Any scripts or data that you put into this service are public.

FREEtree documentation built on July 1, 2020, 6:26 p.m.