class_docstr: XGBoost callback with metrics plotting widget from CatBoost
      
class_docstr_tok: ["XGBoost","callback","with","metrics","plotting","widget","from","CatBoost"]
code: def after_iteration(self, model, epoch, evals_log):
      data_names = evals_log.keys()
      # if more than one sample is passed, consider first as train sample
      first_train = (
          all(
              ["valid" in data_name.lower() for data_name in data_names]
          )
          and len(data_names) > 1
      )
  
      for data_name, metrics_info in evals_log.items():
          if "train" in data_name.lower() or first_train:
              train = True
              first_train = False
          elif (
              "valid" in data_name.lower()
              or "test" in data_name.lower()
          ):
              train = False
          else:
              raise Exception(
                  "Unexpected sample name during evaluation"
              )
  
          metrics = {
              name: values[-1] for name, values in metrics_info.items()
          }
  
          if self.plotter is None:
              names = list(metrics.keys())
              self.plotter = MetricsPlotter(
                  names, names, self.total_iterations
              )
              display(self.plotter._widget)
  
          self.plotter.log(epoch, train, metrics)
  
      # False to indicate training should not stop.
      return False
  
imports: from IPython.display import display
  from .metrics_plotter import MetricsPlotter
label_desc: Use image node_id 2 for calling the XGBPlottingCallback obj's underlying member method code with example usage: obj.after_iteration(model, epoch, evals_log) and returns: False