class_docstr: This class is essentially an API for the AUC object.
  This class contains methods for inspecting the AUC for different criteria.
  To input the different criteria, use the static variable ``criteria``.
docstr: Get the confusion matrix for the specified metric.
  
  :param metrics: A string (or list of strings) among metrics listed in :const:`maximizing_metrics`. Defaults to ``'f1'``.
  :param thresholds: A value (or list of values) between 0 and 1.
      If None, then the thresholds maximizing each provided metric will be used.
  :returns: a list of ConfusionMatrix objects (if there are more than one to return), a single ConfusionMatrix
      (if there is only one), or None if thresholds are metrics scores are missing.
  
  :examples:
  
  >>> from h2o.estimators.gbm import H2OGradientBoostingEstimator
  >>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv")
  >>> cars["cylinders"] = cars["cylinders"].asfactor()
  >>> train, valid = cars.split_frame(ratios=[.8], seed=1234)
  >>> response = "cylinders"
  >>> distribution = "multinomial"
  >>> predictors = ["displacement","power","weight","acceleration","year"]
  >>> gbm = H2OGradientBoostingEstimator(nfolds=3,
  ...                                    distribution=distribution)
  >>> gbm.train(x=predictors,
  ...           y = response,
  ...           training_frame = train,
  ...           validation_frame = valid)
  >>> gbm.confusion_matrix(train)
docstr_tok: ["Get","the","confusion","matrix","for","the","specified","metric",".",":","param","metrics",":","A","string","(","or","list","of","strings",")","among","metrics","listed","in",":","const",":","`","maximizing_metrics","`",".","Defaults","to","``","'f1","'","``",".",":","param","thresholds",":","A","value","(","or","list","of","values",")","between","0","and","1",".","If","None",",","then","the","thresholds","maximizing","each","provided","metric","will","be","used",".",":","returns",":","a","list","of","ConfusionMatrix","objects","(","if","there","are","more","than","one","to","return",")",",","a","single","ConfusionMatrix","(","if","there","is","only","one",")",",","or","None","if","thresholds","are","metrics","scores","are","missing",".",":","examples",":",">",">",">","from","h2o.estimators.gbm","import","H2OGradientBoostingEstimator",">",">",">","cars","=","h2o.import_file","(","``","https",":","\/\/s3.amazonaws.com\/h2o-public-test-data\/smalldata\/junit\/cars_20mpg.csv","''",")",">",">",">","cars","[","``","cylinders","''","]","=","cars","[","``","cylinders","''","]",".asfactor","(",")",">",">",">","train",",","valid","=","cars.split_frame","(","ratios=","[",".8","]",",","seed=1234",")",">",">",">","response","=","``","cylinders","''",">",">",">","distribution","=","``","multinomial","''",">",">",">","predictors","=","[","``","displacement","''",",","''","power","''",",","''","weight","''",",","''","acceleration","''",",","''","year","''","]",">",">",">","gbm","=","H2OGradientBoostingEstimator","(","nfolds=3",",","...","distribution=distribution",")",">",">",">","gbm.train","(","x=predictors",",","...","y","=","response",",","...","training_frame","=","train",",","...","validation_frame","=","valid",")",">",">",">","gbm.confusion_matrix","(","train",")"]
code: def confusion_matrix(self, metrics=None, thresholds=None):
      """
      Get the confusion matrix for the specified metric.
  
      :param metrics: A string (or list of strings) among metrics listed in :const:`maximizing_metrics`. Defaults to ``'f1'``.
      :param thresholds: A value (or list of values) between 0 and 1.
          If None, then the thresholds maximizing each provided metric will be used.
      :returns: a list of ConfusionMatrix objects (if there are more than one to return), a single ConfusionMatrix
          (if there is only one), or None if thresholds are metrics scores are missing.
  
      :examples:
  
      >>> from h2o.estimators.gbm import H2OGradientBoostingEstimator
      >>> cars = h2o.import_file("https://s3.amazonaws.com/h2o-public-test-data/smalldata/junit/cars_20mpg.csv")
      >>> cars["cylinders"] = cars["cylinders"].asfactor()
      >>> train, valid = cars.split_frame(ratios=[.8], seed=1234)
      >>> response = "cylinders"
      >>> distribution = "multinomial"
      >>> predictors = ["displacement","power","weight","acceleration","year"]
      >>> gbm = H2OGradientBoostingEstimator(nfolds=3,
      ...                                    distribution=distribution)
      >>> gbm.train(x=predictors,
      ...           y = response,
      ...           training_frame = train,
      ...           validation_frame = valid)
      >>> gbm.confusion_matrix(train)
      """
      thresh2d = self._metric_json["thresholds_and_metric_scores"]
      if thresh2d is None:
          return None
  
      # make lists out of metrics and thresholds arguments
      if metrics is None and thresholds is None:
          metrics = ["f1"]
  
      if isinstance(metrics, list):
          metrics_list = metrics
      elif metrics is None:
          metrics_list = []
      else:
          metrics_list = [metrics]
  
      if isinstance(thresholds, list):
          thresholds_list = thresholds
      elif thresholds is None:
          thresholds_list = []
      else:
          thresholds_list = [thresholds]
  
      # error check the metrics_list and thresholds_list
      assert_is_type(thresholds_list, [numeric])
      assert_satisfies(
          thresholds_list, all(0 <= t <= 1 for t in thresholds_list)
      )
  
      if not all(
          m.lower() in H2OBinomialModelMetrics.maximizing_metrics
          for m in metrics_list
      ):
          raise ValueError(
              "The only allowable metrics are {}".format(
                  ", ".join(H2OBinomialModelMetrics.maximizing_metrics)
              )
          )
  
      # make one big list that combines the thresholds and metric-thresholds
      metrics_thresholds = [
          self.find_threshold_by_max_metric(m) for m in metrics_list
      ]
      for mt in metrics_thresholds:
          thresholds_list.append(mt)
      first_metrics_thresholds_offset = len(thresholds_list) - len(
          metrics_thresholds
      )
  
      actual_thresholds = [
          float(e[0]) for i, e in enumerate(thresh2d.cell_values)
      ]
      cms = []
      for i, t in enumerate(thresholds_list):
          idx = self.find_idx_by_threshold(t)
          row = thresh2d.cell_values[idx]
          tns = row[11]
          fns = row[12]
          fps = row[13]
          tps = row[14]
          p = tps + fns
          n = tns + fps
          c0 = n - fps
          c1 = p - tps
          if t in metrics_thresholds:
              m = metrics_list[i - first_metrics_thresholds_offset]
              table_header = "Confusion Matrix (Act/Pred) for max {} @ threshold = {}".format(
                  m, actual_thresholds[idx]
              )
          else:
              table_header = (
                  "Confusion Matrix (Act/Pred) @ threshold = {}".format(
                      actual_thresholds[idx]
                  )
              )
          cms.append(
              ConfusionMatrix(
                  cm=[[c0, fps], [c1, tps]],
                  domains=self._metric_json["domain"],
                  table_header=table_header,
              )
          )
  
      if len(cms) == 1:
          return cms[0]
      else:
          return cms
  
imports: import h2o
  from h2o.model import MetricsBase, ConfusionMatrix
  from h2o.plot import get_matplotlib_pyplot, decorate_plot_result, RAISE_ON_FIGURE_ACCESS
  from h2o.utils.metaclass import deprecated_params
  from h2o.utils.shared_utils import List
  from h2o.utils.typechecks import assert_is_type, numeric, is_type, assert_satisfies
label_desc: Use image node_id 29 for calling the H2OBinomialModelMetrics obj's underlying member method code with example usage: obj.confusion_matrix(metrics, thresholds) and returns: None, cms, cms