code: def test_gam_compare_R():
      print("Checking model scoring for gaussian")
      h2o_data = h2o.import_file(
          path=pyunit_utils.locate(
              "smalldata/glm_test/gaussian_20cols_10000Rows.csv"
          )
      )
      h2o_data["C1"] = h2o_data["C1"].asfactor()
      h2o_data["C2"] = h2o_data["C2"].asfactor()
      myY = "C21"
      rDeviance = 36138186581  # total squared residual error
      rmse = math.sqrt(rDeviance / h2o_data.nrow)
  
      gaussModel = buildModelCheckPredict(
          h2o_data,
          myY,
          ["C11", "C12", "C13"],
          "gaussian",
          searchLambda=False,
      )
      gaussModelLS = buildModelCheckPredict(
          h2o_data,
          myY,
          ["C11", "C12", "C13"],
          "gaussian",
          searchLambda=True,
      )
      print(
          "R rmse is {0}.  H2O GAM rmse with mostly default settings: {1}.  H2O GAM rmse with Lambda search enabled: "
          "{2}".format(rmse, gaussModel.rmse(), gaussModelLS.rmse())
      )
      assert (
          abs(min(gaussModelLS.rmse(), gaussModel.rmse()) - rmse)
          / max(min(gaussModelLS.rmse(), gaussModel.rmse()), rmse)
          < 1e-1
      ), (
          "H2O GAM square residual error {0} differs too much from R GAM square residual error "
          "{1}".format(gaussModelLS.rmse(), rmse)
      )
  
      print("Checking model scoring for binomial")
      h2o_data = h2o.import_file(
          pyunit_utils.locate(
              "smalldata/glm_test/binomial_20_cols_10KRows.csv"
          )
      )
      h2o_data["C1"] = h2o_data["C1"].asfactor()
      h2o_data["C2"] = h2o_data["C2"].asfactor()
      rpredAcc = 6931.0 / h2o_data.nrow
      myY = "C21"
      h2o_data["C21"] = h2o_data["C21"].asfactor()
      binomialModel = buildModelCheckPredict(
          h2o_data,
          myY,
          ["C11", "C12", "C13"],
          "binomial",
          searchLambda=False,
          stdardize=True,
      )
      binomialModelLS = buildModelCheckPredict(
          h2o_data,
          myY,
          ["C11", "C12", "C13"],
          "binomial",
          searchLambda=True,
          stdardize=True,
      )
      binomialAcc = binomialModel.accuracy()[0][1]
      binomialLSAcc = binomialModelLS.accuracy()[0][1]
      print(
          "R prediction accuracy: {0}.  H2O GAM prediction accuracy with mostly default settings: {1}.  H2O GAM "
          "prediction accuracy with Lambda search enabled: {2} ".format(
              rpredAcc, binomialAcc, binomialLSAcc
          )
      )
      assert max(binomialAcc, binomialLSAcc) > rpredAcc, (
          "H2O Gam accuracy: {0} is lower than "
          "R Gam accuracy: {1}".format(binomialLSAcc, rpredAcc)
      )
      print("gam compare with R completed successfully")
  
imports: import sys
  import h2o
  from tests import pyunit_utils
  from h2o.estimators.gam import H2OGeneralizedAdditiveEstimator
  import math
label_desc: Use image node_id 1 for calling a global function with example usage: test_gam_compare_R() without return types