code: def gbm(interactive=True, echo=True, testing=False):
      """GBM model demo."""
  
      def demo_body(go):
          """
          Demo of H2O's Gradient Boosting estimator.
  
          This demo uploads a dataset to h2o, parses it, and shows a description.
          Then it divides the dataset into training and test sets, builds a GLM
          from the training set, and makes predictions for the test set.
          Finally, default performance metrics are displayed.
          """
          go()
          # Connect to H2O
          h2o.init()
  
          go()
          # Upload the prostate dataset that comes included in the h2o python package
          prostate = h2o.load_dataset("prostate")
  
          go()
          # Print a description of the prostate data
          prostate.describe()
  
          go()
          # Randomly split the dataset into ~70/30, training/test sets
          train, test = prostate.split_frame(ratios=[0.70])
  
          go()
          # Convert the response columns to factors (for binary classification problems)
          train["CAPSULE"] = train["CAPSULE"].asfactor()
          test["CAPSULE"] = test["CAPSULE"].asfactor()
  
          go()
          # Build a (classification) GLM
          from h2o.estimators import H2OGradientBoostingEstimator
  
          prostate_gbm = H2OGradientBoostingEstimator(
              distribution="bernoulli",
              ntrees=10,
              max_depth=8,
              min_rows=10,
              learn_rate=0.2,
          )
          prostate_gbm.train(
              x=["AGE", "RACE", "PSA", "VOL", "GLEASON"],
              y="CAPSULE",
              training_frame=train,
          )
  
          go()
          # Show the model
          prostate_gbm.show()
  
          go()
          # Predict on the test set and show the first ten predictions
          predictions = prostate_gbm.predict(test)
          predictions.show()
  
          go()
          # Fetch a tree, print number of tree nodes, show root node description
          from h2o.tree import H2OTree, H2ONode
  
          tree = H2OTree(prostate_gbm, 0, "0")
          len(tree)
          tree.left_children
          tree.right_children
          tree.root_node.show()
  
          go()
          # Show default performance metrics
          performance = prostate_gbm.model_performance(test)
          performance.show()
  
      # Execute:
      _run_demo(demo_body, interactive, echo, testing)
  
file_path: h2o-3/h2o-py/h2o/demos.py
imports: from h2o.utils.compatibility import *
  import linecache
  import os
  import sys
  import h2o
  from h2o.utils.typechecks import assert_is_type
label_desc: Use image node_id 1 for calling a global function with example usage: gbm(interactive, echo, testing) without return types