code: def test_metrics_gbm():
      """
      test metrics values from the Permutation Variable Importance
      """
      # train model
      (
          model,
          fr,
      ) = (
          gbm_model_build()
      )  # type: Tuple[h2o.model.ModelBase, H2OFrame]
  
      # case H2OFrame
      pm_h2o_df = model.permutation_importance(
          fr, use_pandas=False, metric="AUC"
      )
      for col in [
          "Relative Importance",
          "Scaled Importance",
          "Percentage",
      ]:
          assert isinstance(pm_h2o_df[col][0], float)
  
      # range in all tests is [1, ncols], first column is str: Importance
      assert is_type(pm_h2o_df[0][0], str)
      # case pandas
      pm_pd_df = model.permutation_importance(
          fr, use_pandas=True, metric="AUC"
      )
      for col in pm_pd_df.columns:
          assert isinstance(pm_pd_df.iloc[0][col], float)
  
      metrics = ["AUTO", "MSE", "RMSE", "AUC", "logloss"]
      for metric in metrics:
          pd_pfi = model.permutation_importance(
              fr, use_pandas=False, metric=metric
          )
          for col in pd_pfi.col_header[1:]:
              assert isinstance(pd_pfi[col][0], float)
  
      for metric in metrics:
          pd_pfi = model.permutation_importance(
              fr, use_pandas=False, n_repeats=5, metric=metric
          )
          for i, col in enumerate(pd_pfi.col_header[1:]):
              assert col == "Run {}".format(1 + i)
              assert isinstance(pd_pfi[col][0], float)
  
      try:
          pfi = model.permutation_importance(
              fr, use_pandas=False, n_samples=0, features=[], seed=42
          )
          assert False, "This should fail on validation - n_samples=0."
      except h2o.exceptions.H2OValueError:
          pass
  
      try:
          pfi = model.permutation_importance(
              fr, use_pandas=False, n_repeats=0, features=[], seed=42
          )
          assert (
              False
          ), "This should fail on validation - n_repeats = 0."
      except h2o.exceptions.H2OValueError:
          pass
  
      try:
          pfi = model.permutation_importance(
              fr[["AGE", "PSA"]], use_pandas=False, seed=42
          )
          assert (
              False
          ), "This should fail on validation - missing response."
      except h2o.exceptions.H2OValueError:
          pass
  
      try:
          pfi = model.permutation_importance(
              fr,
              use_pandas=False,
              features=["lorem", "ipsum", "dolor"],
              seed=42,
          )
          assert (
              False
          ), "This should fail on validation - non-existent features."
      except h2o.exceptions.H2OValueError:
          pass
  
      try:
          pfi = model.permutation_importance(
              fr, use_pandas=False, n_samples=1, features=[]
          )
          assert (
              False
          ), "This should throw an exception since we cannot permute one row."
      except h2o.exceptions.H2OValueError:
          pass
  
      pfi = model.permutation_importance(
          fr, use_pandas=False, n_samples=10, features=[]
      )
      for col in pfi.col_header[1:]:
          assert isinstance(pfi[col][0], float)
  
      pfi = model.permutation_importance(
          fr, use_pandas=False, n_samples=-1, features=["PSA"]
      )
      assert len(pfi.cell_values) == 1  # "[(PSA, ..., ..., ...)]"
      for col in pfi.col_header[1:]:
          assert isinstance(pfi[col][0], float)
  
      pfi = model.permutation_importance(
          fr, use_pandas=False, n_samples=-1, features=["PSA", "AGE"]
      )
      assert len(pfi.cell_values) == 2
      for col in pfi.col_header[1:]:
          assert isinstance(pfi[col][0], float)
  
file_path: h2o-3/h2o-py/tests/testdir_jira/pyunit_pubdev_7139_permutation_var_imp.py
imports: import sys, os
  import h2o
  from h2o.utils.typechecks import is_type
  from h2o.estimators import H2OGradientBoostingEstimator, H2OGeneralizedLinearEstimator
  from tests import pyunit_utils
label_desc: Use image node_id 2 for calling a global function with example usage: test_metrics_gbm() without return types