code: def glm(interactive=True, echo=True, testing=False):
      """GLM model demo."""
  
      def demo_body(go):
          """
          Demo of H2O's Generalized Linear 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 H2OGeneralizedLinearEstimator
  
          prostate_glm = H2OGeneralizedLinearEstimator(
              family="binomial", alpha=[0.5]
          )
          prostate_glm.train(
              x=["AGE", "RACE", "PSA", "VOL", "GLEASON"],
              y="CAPSULE",
              training_frame=train,
          )
  
          go()
          # Show the model
          prostate_glm.show()
  
          go()
          # Predict on the test set and show the first ten predictions
          predictions = prostate_glm.predict(test)
          predictions.show()
  
          go()
          # Show default performance metrics
          performance = prostate_glm.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 3 for calling a global function with example usage: glm(interactive, echo, testing) without return types