Tree Class in H2O

H2O Tree Class

class h2o.tree.H2OTree(model, tree_number, tree_class=None)[source]

Bases: object

Represents a model of a Tree built by one of H2O’s tree algorithms (GBM, Random Forest, XGBoost, Isolation Forest).

The internal structure mimics the behavior of Scikit’s internal tree representation and contains all the information available about every node in the graph. (https://scikit-learn.org/stable/auto_examples/tree/plot_unveil_tree_structure.html) It provides both human-readable output and formatting suitable for machine processing.

In the fetched object, there are two representations of the graph contained:

  • graph-oriented representation, starting with a root node with edges

  • array/vector representation, useful for quick machine processing of the tree’s structure

Every graph starts with a root node, which is in fact an instance of H2OSplitNode and is naturally the very beginning of all decision paths in the graph. It points to its children, which again point to their children, unless an H2OLeafNode is hit. Nodes are always numbered from the top of the tree down to the lowest level, from left to right.

At the tree level, the following information is provided:

  • Number of nodes in the tree

  • Model the tree belongs to

  • Tree class (if applicable,

  • Pointer to a root node for tree traversal (breadth-first, depth-first) and manual tree walking

Each node in the tree is uniquely identified by an ID, regardless of its type. Also for each node type, a human-redable description is available. There are two types nodes distinguished:

  • Split node

  • Leaf node

Split Node: A split node is a single non-terminal node with either numerical or categorical feature split. The root node is guaranteed to be a split node, as a zero-depth tree \(t\) of cardinality \(|t| = 1\) contains no decisions at all. Every split node consists of:

  1. H2O-specific node identifier (ID - all nodes have it)

  2. Left child node & right child node

  3. Split feature name (split column name)

  4. Split threshold (mainly for numerical splits)

  5. Categorical features split (categorical splits only)

  6. Direction of NA values (which way NA values go - left child, right child, or nowhere)

Leaf Node: A leaf node is a single node with no children, thus being a terminal node at the end of the decision path in a tree. Leaf node consists of:

  1. H2O-specific node identifier (ID - all nodes have it)

  2. Prediction value (floating point number)

Parameters
  • model – The model this tree is related to.

  • tree_number – An integer representing the order in which the tree has been built in the model.

  • tree_class – A string representing the name of the tree’s class. Specifies the class of the tree requested. Required for multi-class classification. The number of tree classes equals the number of levels in categorical response column. As there is exactly one class per categorical level, the name of the tree’s class is equal to the corresponding categorical level of the response column. In case of regression and binomial models, the name of the categorical level is ignored and can be omitted.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> # Obtaining a tree is a matter of a single call
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.model_id
>>> tree.tree_number
>>> tree.tree_class
property descriptions

Descriptions for each node to be found in the tree, in human-readable format. Provides a human-readable summary of each node. Contains split threshold if the split is based on numerical column. For categorical splits, it contains a list of categorical levels for transition from the parent node.

Use the node’s ID to access the description for a given node in the underlying array.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.descriptions
property features

Names of the feature/column used for the split. The array tells which feature is used for the split on a given node.

Use the node’s ID to access the split feature for a given node in the underlying array.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.features
property left_children

An array with left child nodes of tree’s nodes. Holds indices of each node’s left child.

Use the node’s ID to obtain the index of the left child for a given node in the underlying array.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.left_children
property levels

Categorical levels on the split from the parent’s node belonging into this node. None for root node or non-categorical splits. Show list of categorical levels inherited by each node from the parent.

Use the node’s ID to access inherited categorical levels for a given node in the underlying array.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.levels
property model_id

Name (identification) of the model this tree is related to.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.model_id
property nas

NA value direction on split. Shows whether NA values go to the left node or the right node. The value may be None if node is a leaf or if there is no possibility of an NA value occuring during a split, typically due to filtering all NAs out to a different path in the graph.

Use the node’s ID to access NA direction for a given node in the underlying array.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.nas
property node_ids

Array with identification numbers of nodes. Node IDs are generated by H2O. Serves as the node’s unique identifier inside H2O. (May differ from index.) Nodes are always numbered from the top of the tree down to the lowest level, from left to right.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.node_ids
property predictions

Values predicted on tree’s nodes.

Use the node’s ID to access predictions for a given node in the underlying array.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.predictions
property right_children

An array with right child nodes of tree’s nodes. Holds indices of each node’s right child.

Use node’s ID to obtain index of the right child for given node in the underlying array.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.right_children
property root_node

An instance of H2ONode representing the beginning of the tree behind the model. Allows further tree traversal.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.root_node
show()[source]

Summarizes the H2OTree.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.show()
property thresholds

Node split thresholds. Split thresholds are not only related to numerical splits but might be present in case of categorical split as well.

Use the node’s ID to access the threshold for a given node in the underlying array.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.thresholds
property tree_class

The name of a tree’s class.

The number of tree classes equals the number of levels in the categorical response column. As there is exactly one class per categorical level, the name of tree’s class is equal to the corresponding categorical level of the response column.

In the case of regression and binomial, the name of the categorical level is ignored and can be omitted, as there is exactly one tree built in both cases.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.tree_class
property tree_number

The order in which the tree has been built in the model.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.tree_number

H2O Node Class

class h2o.tree.H2ONode(node_id)[source]

Bases: object

Represents a single abstract node in an H2OTree.

Parameters

id – Node’s unique identifier (integer). Generated by H2O.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2ONode
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.node_ids
property id

Node’s unique identifier (integer). Generated by H2O.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2ONode
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines= h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/allyears2k_headers.zip")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.node_ids
>>> node0 = H2ONode(0)
>>> node0

H2O Leaf Node Class

class h2o.tree.H2OLeafNode(node_id, prediction)[source]

Bases: h2o.tree.tree.H2ONode

Represents a single terminal node in an H2OTree with final prediction.

Parameters
  • id – Node’s unique identifier (integer). Generated by H2O.

  • prediction – The prediction value in the terminal node (numeric floating point).

Examples

>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2OLeafNode
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
# Retrieve the node ids      
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.node_ids
# Retrieve the predictions
>>> tree.predictions
# Set the id and prediction
>>> H2OLeafNode(0, -0.23001842)
property id

Node’s unique identifier (integer). Generated by H2O.

Examples

>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2OLeafNode
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
# Retrieve the node ids      
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.node_ids
# Retrieve the predictions
>>> tree.predictions
# Set the id and prediction
>>> leaf_node = H2OLeafNode(0, -0.23001842)
# Retrieve the node id
>>> leaf_node.id        
property prediction

Prediction value in the terminal node (numeric floating point).

Examples

>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2OLeafNode
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
# Retrieve the node ids      
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.node_ids
# Retrieve the predictions
>>> tree.predictions
# Set the id and prediction
>>> leaf_node = H2OLeafNode(0, -0.23001842)
# Retrieve the node prediction
>>> leaf_node.prediction
show()[source]
Examples

>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2OLeafNode
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin", "Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
# Retrieve the predictions
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> tree.predictions
# Retrieve predicted value for a node
>>> leaf_node = H2OLeafNode(0, -0.23001842)
>>> leaf_node.show()

H2O Split Node Class

class h2o.tree.H2OSplitNode(node_id, threshold, left_child, right_child, split_feature, na_direction, left_levels, right_levels)[source]

Bases: h2o.tree.tree.H2ONode

Represents a single node with either numerical or categorical split in an H2OTree with all its attributes.

Parameters
  • id – Node’s unique identifier (integer). Generated by H2O.

  • threshold – Split threshold, typically when the split column is numerical.

  • left_child – Integer identifier of the left child node, if there is any. Otherwise None.

  • right_child – Integer identifier of the right child node, if there is and. Otherwise None.

  • split_feature – The name of the column this node splits on.

  • na_direction – The direction of NA values. LEFT means NA values go to the left child node; RIGHT means NA values go to the right child node. A value of None means occurence of NA for the given split column is not possible on this node due to an earlier split on the very same feature.

  • left_levels – Categorical levels on the edge from this node to the left child node. None for non-categorical splits.

  • right_levels – Categorical levels on the edge from this node to the right cild node. None for non-categorical splits.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2OSplitNode
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin","Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> threshold = 'nan'
>>> left_child = 9
>>> right_child = 10
>>> split_feature = "DepTime"
>>> na_direction = "Left"
>>> left_levels = ['FAT', 'LAS', 'PSP']
>>> right_levels = ['BWI', 'CLT', 'IND', 'MCO',
...                 'PHL', 'PHX', 'RIC', 'TPA']
>>> H2OSplitNode(5, threshold, left_child,
...              right_child, split_feature,
...              na_direction, left_levels,
...              right_levels)
property id

Node’s unique identifier (integer). Generated by H2O.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2OSplitNode
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin","Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> threshold = 'nan'
>>> left_child = 9
>>> right_child = 10
>>> split_feature = "DepTime"
>>> na_direction = "Left"
>>> left_levels = ['FAT', 'LAS', 'PSP']
>>> right_levels = ['BWI', 'CLT', 'IND', 'MCO',
...                 'PHL', 'PHX', 'RIC', 'TPA']
>>> split_node = H2OSplitNode(5, threshold, left_child,
...                           right_child, split_feature,
...                           na_direction, left_levels,
...                           right_levels)
>>> split_node.id
property left_child

Integer identifier of the left child node, if there is any. Otherwise None.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2OSplitNode
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin","Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> threshold = 'nan'
>>> left_child = 9
>>> right_child = 10
>>> split_feature = "DepTime"
>>> na_direction = "Left"
>>> left_levels = ['FAT', 'LAS', 'PSP']
>>> right_levels = ['BWI', 'CLT', 'IND', 'MCO',
...                 'PHL', 'PHX', 'RIC', 'TPA']
>>> split_node = H2OSplitNode(5, threshold, left_child,
...                           right_child, split_feature,
...                           na_direction, left_levels,
...                           right_levels)
>>> split_node.left_child
property left_levels

Categorical levels on the edge from this node to the left child node. None for non-categorical splits.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2OSplitNode
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin","Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> threshold = 'nan'
>>> left_child = 9
>>> right_child = 10
>>> split_feature = "DepTime"
>>> na_direction = "Left"
>>> left_levels = ['FAT', 'LAS', 'PSP']
>>> right_levels = ['BWI', 'CLT', 'IND', 'MCO',
...                 'PHL', 'PHX', 'RIC', 'TPA']
>>> split_node = H2OSplitNode(5, threshold, left_child,
...                           right_child, split_feature,
...                           na_direction, left_levels,
...                           right_levels)
>>> split_node.left_levels
property na_direction

The direction of NA values. LEFT means NA values go to the left child node; RIGHT means NA values go to the right child node. A value of None means occurance of NA for the given split column is not possible on this node due to an earlier split on the very same feature.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2OSplitNode
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin","Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> threshold = 'nan'
>>> left_child = 9
>>> right_child = 10
>>> split_feature = "DepTime"
>>> na_direction = "Left"
>>> left_levels = ['FAT', 'LAS', 'PSP']
>>> right_levels = ['BWI', 'CLT', 'IND', 'MCO',
...                 'PHL', 'PHX', 'RIC', 'TPA']
>>> split_node = H2OSplitNode(5, threshold, left_child,
...                           right_child, split_feature,
...                           na_direction, left_levels,
...                           right_levels)
>>> split_node.na_direction
property right_child

Integer identifier of the right child node, if there is any. Otherwise None.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2OSplitNode
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin","Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> threshold = 'nan'
>>> left_child = 9
>>> right_child = 10
>>> split_feature = "DepTime"
>>> na_direction = "Left"
>>> left_levels = ['FAT', 'LAS', 'PSP']
>>> right_levels = ['BWI', 'CLT', 'IND', 'MCO',
...                 'PHL', 'PHX', 'RIC', 'TPA']
>>> split_node = H2OSplitNode(5, threshold, left_child,
...                           right_child, split_feature,
...                           na_direction, left_levels,
...                           right_levels)
>>> split_node.right_child
property right_levels

Categorical levels on the edge from this node to the right child node. None for non-categorical splits.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2OSplitNode
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin","Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> threshold = 'nan'
>>> left_child = 9
>>> right_child = 10
>>> split_feature = "DepTime"
>>> na_direction = "Left"
>>> left_levels = ['FAT', 'LAS', 'PSP']
>>> right_levels = ['BWI', 'CLT', 'IND', 'MCO',
...                 'PHL', 'PHX', 'RIC', 'TPA']
>>> split_node = H2OSplitNode(5, threshold, left_child,
...                           right_child, split_feature,
...                           na_direction, left_levels,
...                           right_levels)
>>> split_node.right_levels
show()[source]
Examples

>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2OSplitNode
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin","Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> threshold = 'nan'
>>> left_child = 9
>>> right_child = 10
>>> split_feature = "DepTime"
>>> na_direction = "Left"
>>> left_levels = ['FAT', 'LAS', 'PSP']
>>> right_levels = ['BWI', 'CLT', 'IND', 'MCO',
...                 'PHL', 'PHX', 'RIC', 'TPA']
>>> split_node = H2OSplitNode(5, threshold, left_child,
...                           right_child, split_feature,
...                           na_direction, left_levels,
...                           right_levels)
>>> split_node.show
property split_feature

The name of the column this node splits on.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2OSplitNode
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin","Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> threshold = 'nan'
>>> left_child = 9
>>> right_child = 10
>>> split_feature = "DepTime"
>>> na_direction = "Left"
>>> left_levels = ['FAT', 'LAS', 'PSP']
>>> right_levels = ['BWI', 'CLT', 'IND', 'MCO',
...                 'PHL', 'PHX', 'RIC', 'TPA']
>>> split_node = H2OSplitNode(5, threshold, left_child,
...                           right_child, split_feature,
...                           na_direction, left_levels,
...                           right_levels)
>>> split_node.split_feature
property threshold

Split threshold for each node. Not only numerical features have numerical split. For splits on categorical features, the numerical split threshold represents an index in the categorical feature’s domain.

Examples

>>> from h2o.tree import H2OTree
>>> from h2o.tree import H2OSplitNode
>>> from h2o.estimators import H2OGradientBoostingEstimator
>>> airlines = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/airlines/AirlinesTrain.csv")
>>> gbm = H2OGradientBoostingEstimator(ntrees=1)
>>> gbm.train(x=["Origin","Dest"],
...           y="IsDepDelayed",
...           training_frame=airlines)
>>> tree = H2OTree(model = gbm, tree_number = 0 , tree_class = "NO")
>>> threshold = 'nan'
>>> left_child = 9
>>> right_child = 10
>>> split_feature = "DepTime"
>>> na_direction = "Left"
>>> left_levels = ['FAT', 'LAS', 'PSP']
>>> right_levels = ['BWI', 'CLT', 'IND', 'MCO',
...                 'PHL', 'PHX', 'RIC', 'TPA']
>>> split_node = H2OSplitNode(5, threshold, left_child,
...                           right_child, split_feature,
...                           na_direction, left_levels,
...                           right_levels)
>>> split_node.threshold