class_docstr: Base class for AdaBoost estimators.
  
  Warning: This class should not be used directly. Use derived classes
  instead.
class_docstr_tok: ["Base","class","for","AdaBoost","estimators",".","Warning",":","This","class","should","not","be","used","directly",".","Use","derived","classes","instead","."]
docstr: Build a boosted classifier/regressor from the training set (X, y).
  
  Parameters
  ----------
  X : {array-like, sparse matrix} of shape (n_samples, n_features)
      The training input samples. Sparse matrix can be CSC, CSR, COO,
      DOK, or LIL. COO, DOK, and LIL are converted to CSR.
  
  y : array-like of shape (n_samples,)
      The target values.
  
  sample_weight : array-like of shape (n_samples,), default=None
      Sample weights. If None, the sample weights are initialized to
      1 / n_samples.
  
  Returns
  -------
  self : object
      Fitted estimator.
docstr_tok: ["Build","a","boosted","classifier\/regressor","from","the","training","set","(","X",",","y",")",".","Parameters","--","--","--","--","--","X",":","{","array-like",",","sparse","matrix","}","of","shape","(","n_samples",",","n_features",")","The","training","input","samples",".","Sparse","matrix","can","be","CSC",",","CSR",",","COO",",","DOK",",","or","LIL",".","COO",",","DOK",",","and","LIL","are","converted","to","CSR",".","y",":","array-like","of","shape","(","n_samples",",",")","The","target","values",".","sample_weight",":","array-like","of","shape","(","n_samples",",",")",",","default=None","Sample","weights",".","If","None",",","the","sample","weights","are","initialized","to","1","\/","n_samples",".","Returns","--","--","--","-","self",":","object","Fitted","estimator","."]
code: def fit(self, X, y, sample_weight=None):
      """Build a boosted classifier/regressor from the training set (X, y).
  
      Parameters
      ----------
      X : {array-like, sparse matrix} of shape (n_samples, n_features)
          The training input samples. Sparse matrix can be CSC, CSR, COO,
          DOK, or LIL. COO, DOK, and LIL are converted to CSR.
  
      y : array-like of shape (n_samples,)
          The target values.
  
      sample_weight : array-like of shape (n_samples,), default=None
          Sample weights. If None, the sample weights are initialized to
          1 / n_samples.
  
      Returns
      -------
      self : object
          Fitted estimator.
      """
      X, y = self._validate_data(
          X,
          y,
          accept_sparse=["csr", "csc"],
          ensure_2d=True,
          allow_nd=True,
          dtype=None,
          y_numeric=is_regressor(self),
      )
  
      sample_weight = _check_sample_weight(
          sample_weight,
          X,
          np.float64,
          copy=True,
          only_non_negative=True,
      )
      sample_weight /= sample_weight.sum()
  
      # Check parameters
      self._validate_estimator()
  
      # Clear any previous fit results
      self.estimators_ = []
      self.estimator_weights_ = np.zeros(
          self.n_estimators, dtype=np.float64
      )
      self.estimator_errors_ = np.ones(
          self.n_estimators, dtype=np.float64
      )
  
      # Initialization of the random number instance that will be used to
      # generate a seed at each iteration
      random_state = check_random_state(self.random_state)
      epsilon = np.finfo(sample_weight.dtype).eps
  
      zero_weight_mask = sample_weight == 0.0
      for iboost in range(self.n_estimators):
          # avoid extremely small sample weight, for details see issue #20320
          sample_weight = np.clip(
              sample_weight, a_min=epsilon, a_max=None
          )
          # do not clip sample weights that were exactly zero originally
          sample_weight[zero_weight_mask] = 0.0
  
          # Boosting step
          (
              sample_weight,
              estimator_weight,
              estimator_error,
          ) = self._boost(iboost, X, y, sample_weight, random_state)
  
          # Early termination
          if sample_weight is None:
              break
          self.estimator_weights_[iboost] = estimator_weight
          self.estimator_errors_[iboost] = estimator_error
  
          # Stop if error is zero
          if estimator_error == 0:
              break
  
          sample_weight_sum = np.sum(sample_weight)
  
          if not np.isfinite(sample_weight_sum):
              warnings.warn(
                  (
                      "Sample weights have reached infinite values,"
                      f" at iteration {iboost}, causing overflow. "
                      "Iterations stopped. Try lowering the learning rate."
                  ),
                  stacklevel=2,
              )
              break
  
          # Stop if the sum of sample weights has become non-positive
          if sample_weight_sum <= 0:
              break
  
          if iboost < self.n_estimators - 1:
              # Normalize
              sample_weight /= sample_weight_sum
  
      return self
  
imports: import warnings
  from abc import ABCMeta, abstractmethod
  from numbers import Integral, Real
  import numpy
  from scipy.special import xlogy
  from ..base import ClassifierMixin, RegressorMixin, _fit_context, is_classifier, is_regressor
  from ..metrics import accuracy_score, r2_score
  from ..tree import DecisionTreeClassifier, DecisionTreeRegressor
  from ..utils import _safe_indexing, check_random_state
  from ..utils._param_validation import HasMethods, Interval, StrOptions
  from ..utils.extmath import softmax, stable_cumsum
  from ..utils.validation import _check_sample_weight, _num_samples, check_is_fitted, has_fit_parameter
  from ._base import BaseEnsemble
label_desc: Use image node_id 3 for calling the BaseWeightBoosting obj's underlying member method code with example usage: obj.fit(X, y, sample_weight) and returns: self