Description Usage Arguments Value Examples
Takes a h2o tree based model (gbm or drf) and returns a list
of
data.frame
s 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.
1 2 | h2o_tree_convertR_via_mojo(h2o_model, output_subdir = getwd(),
get_internal_predictions = FALSE, delete_intermediate_files = TRUE)
|
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 |
|
delete_intermediate_files |
should intermediate files output in
processing be deleted? Default = |
returns a list
containing a data.frame
for each tree
containing the tree structure. Tree structure data.frame
s contain the
following columns;
"node" name of the node in the tree
"node_text" complete text associated with the node
"predictions" predicted values for terminal nodes or NA
"left_split" left child node or NA if a terminal node
"right_split" right child node or NA if a terminal node
"left_split_levels" levels of the split variable that are sent to the left child node from the current node, separated by |
"right_split_levels" levels of the split variable that are sent to the left child node from the current node, separated by |
"NA_direction" the direction missing values are sent from the current node
"node_text_label" the label arg of node_text, specifically the split condition for numeric split variables or the variable name for categorical variables
"node_variable_type" split variable type for node, either categorical or numeric
"split_column" the name of the split column for the current node
"node_split_point" the split value for the current node if numeric, otherwise NA
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.