h2o_tree_convertR_via_mojo: Convert h2o gbm or drf to tabular structure via mojo

Description Usage Arguments Value Examples

Description

Takes a h2o tree based model (gbm or drf) and returns a list of data.frames representing each tree in the model in tabular structure. In order to access the tree internals this functions exports the h2o model to a mojo .zip and reads the .gv files from within.

Usage

1
2
h2o_tree_convertR_via_mojo(h2o_model, output_subdir = getwd(),
  get_internal_predictions = FALSE, delete_intermediate_files = TRUE)

Arguments

h2o_model

gbm or drf h2o model.

output_subdir

directory to output intermediate files (mojo .zip, .gv and model.ini files) to. Default is location is current working dir. Files are put into a sudir with date-time in name to avoid conflicts.

get_internal_predictions

logical default = FALSE, should predictions for internal (non-terminal nodes) be extracted?

delete_intermediate_files

should intermediate files output in processing be deleted? Default = TRUE.

Value

returns a list containing a data.frame for each tree containing the tree structure. Tree structure data.frames contain the following columns;

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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"])

expl_cols <- c("AGE", "RACE", "DPROS", "DCAPS", "PSA", "VOL", "GLEASON")

prostate.gbm = h2o.gbm(x = expl_cols,
                       y = "CAPSULE",
                       training_frame = prostate.hex,
                       ntrees = 5,
                       max_depth = 5,
                       learn_rate = 0.1)

h2o_trees <- h2o_tree_convertR_via_mojo(h2o_model = prostate.gbm)

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