code: def test_custom_metric_with_isotonic_regression():
      df = h2o.import_file(
          path=pyunit_utils.locate(
              "smalldata/gbm_test/ecology_model.csv"
          )
      )
      df["Angaus"] = df["Angaus"].asfactor()
  
      train, calib = df.split_frame(
          ratios=[0.5],
          destination_frames=["eco_train", "eco_calib"],
          seed=42,
      )
  
      model = H2OGradientBoostingEstimator(
          ntrees=100, distribution="bernoulli", min_rows=10, max_depth=5
      )
      model.train(
          x=list(range(2, train.ncol)),
          y="Angaus",
          training_frame=train,
          validation_frame=calib,
      )
  
      preds_calib = model.predict(calib)
      isotonic_train = calib[["Angaus"]]
      isotonic_train = isotonic_train.cbind(preds_calib["p1"])
  
      logloss = custom_logloss_mm()
  
      h2o_iso_reg = H2OIsotonicRegressionEstimator(
          out_of_bounds="clip", custom_metric_func=logloss
      )
      h2o_iso_reg.train(
          training_frame=isotonic_train, x="p1", y="Angaus"
      )
      print(h2o_iso_reg)
  
      ir_perf = h2o_iso_reg.model_performance(train=True)._metric_json
      model_valid_logloss = model.model_performance(
          valid=True
      ).logloss()
      assert ir_perf["custom_metric_name"] == "logloss"
      # this has to be true because IR actually sees the true response
      assert ir_perf["custom_metric_value"] < model_valid_logloss
  
file_path: h2o-3/h2o-py/tests/testdir_algos/isotonic/pyunit_isotonic_custom_metric.py
imports: import sys
  import h2o
  from tests import pyunit_utils
  from h2o.estimators.gbm import H2OGradientBoostingEstimator
  from h2o.estimators.isotonicregression import H2OIsotonicRegressionEstimator
label_desc: Use image node_id 2 for calling a global function with example usage: test_custom_metric_with_isotonic_regression() without return types