encode_terminal_nodes_df: Encode input data as terminal nodes for single tree.

Description Usage Arguments Value Examples

Description

This function returns the results as a data.frame.

Usage

1
2
encode_terminal_nodes_df(data, terminal_node_split_rules, h2o_tree_in_R,
  tree_name = "tree_", return_one_hot = TRUE)

Arguments

data

input data to encode as terminal nodes from trees. Currently only data.frame inputs are supported.

terminal_node_split_rules

splitting rules for terminal nodes in a single tree, the output from extract_split_rules function.

h2o_tree_in_R

single tree output from h2o_tree_model_to_R function.

tree_name

the prefix to be given to column names. Columns will be named prefix followed by the name of the terminal node. Default = 'tree_'.

Value

terminal node encoding for input data. Currently only data.frame is output.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
library(h2o)

h2o.init()

prostate.hex = h2o.uploadFile(path = system.file("extdata",
                                                 "prostate.csv",
                                                 package = "h2o"),
                              destination_frame = "prostate.hex")

prostate.hex$RACE <- as.factor(prostate.hex$RACE)

prostate.hex$DPROS <- as.factor(prostate.hex$DPROS)

prostate.gbm = h2o.gbm(x = c("AGE", "RACE", "DPROS", "DCAPS", "PSA", "VOL", "GLEASON"),
                       y = "CAPSULE",
                       training_frame = prostate.hex,
                       ntrees = 5,
                       max_depth = 5,
                       learn_rate = 0.1)

h2o_trees <- H2OTreeConvertR::h2o_tree_convertR(prostate.gbm)

h2o_trees_terminal_node_rules <- extract_split_rules(h2o_trees)

terminal_node_encoding_tree1 <- encode_terminal_nodes(data = prostate_df,
                                                      terminal_node_split_rules = h2o_trees_terminal_node_rules[[1]],
                                                      h2o_trees_in_R = h2o_trees[[1]])

richardangell/h2oTreeHelpR documentation built on July 3, 2019, 7:35 a.m.