class_docstr: Callback function for early stopping
  
  .. versionadded:: 1.3.0
  
  Parameters
  ----------
  rounds :
      Early stopping rounds.
  metric_name :
      Name of metric that is used for early stopping.
  data_name :
      Name of dataset that is used for early stopping.
  maximize :
      Whether to maximize evaluation metric.  None means auto (discouraged).
  save_best :
      Whether training should return the best model or the last model.
  min_delta :
  
      .. versionadded:: 1.5.0
  
      Minimum absolute change in score to be qualified as an improvement.
  
  Examples
  --------
  
  .. code-block:: python
  
      es = xgboost.callback.EarlyStopping(
          rounds=2,
          min_delta=1e-3,
          save_best=True,
          maximize=False,
          data_name="validation_0",
          metric_name="mlogloss",
      )
      clf = xgboost.XGBClassifier(tree_method="hist", device="cuda", callbacks=[es])
  
      X, y = load_digits(return_X_y=True)
      clf.fit(X, y, eval_set=[(X, y)])
class_docstr_tok: ["Callback","function","for","early","stopping","..","versionadded",":",":","1.3.0","Parameters","--","--","--","--","--","rounds",":","Early","stopping","rounds",".","metric_name",":","Name","of","metric","that","is","used","for","early","stopping",".","data_name",":","Name","of","dataset","that","is","used","for","early","stopping",".","maximize",":","Whether","to","maximize","evaluation","metric",".","None","means","auto","(","discouraged",")",".","save_best",":","Whether","training","should","return","the","best","model","or","the","last","model",".","min_delta",":","..","versionadded",":",":","1.5.0","Minimum","absolute","change","in","score","to","be","qualified","as","an","improvement",".","Examples","--","--","--","--","..","code-block",":",":","python","es","=","xgboost.callback.EarlyStopping","(","rounds=2",",","min_delta=1e-3",",","save_best=True",",","maximize=False",",","data_name=","''","validation_0","''",",","metric_name=","''","mlogloss","''",",",")","clf","=","xgboost.XGBClassifier","(","tree_method=","''","hist","''",",","device=","''","cuda","''",",","callbacks=","[","es","]",")","X",",","y","=","load_digits","(","return_X_y=True",")","clf.fit","(","X",",","y",",","eval_set=","[","(","X",",","y",")","]",")"]
code: def __init__(
      self,
      rounds: int,
      metric_name: Optional[str] = None,
      data_name: Optional[str] = None,
      maximize: Optional[bool] = None,
      save_best: Optional[bool] = False,
      min_delta: float = 0.0,
  ) -> None:
      self.data = data_name
      self.metric_name = metric_name
      self.rounds = rounds
      self.save_best = save_best
      self.maximize = maximize
      self.stopping_history: TrainingCallback.EvalsLog = {}
      self._min_delta = min_delta
      if self._min_delta < 0:
          raise ValueError("min_delta must be greater or equal to 0.")
  
      self.current_rounds: int = 0
      self.best_scores: dict = {}
      self.starting_round: int = 0
      super().__init__()
  
imports: import collections
  import os
  import pickle
  from abc import ABC
  from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, TypeVar, Union, cast
  import numpy
  from .None import collective
  from .core import Booster, DMatrix, XGBoostError, _parse_eval_str
label_desc: Use image node_id 1 to create a new EarlyStopping object from inherited base classes: TrainingCallback with example: obj = EarlyStopping(rounds, metric_name, data_name, maximize, save_best, min_delta)