class_docstr: Base class for Bagging meta-estimator.
  
  Warning: This class should not be used directly. Use derived classes
  instead.
class_docstr_tok: ["Base","class","for","Bagging","meta-estimator",".","Warning",":","This","class","should","not","be","used","directly",".","Use","derived","classes","instead","."]
docstr: Build a Bagging ensemble of estimators from the training
     set (X, y).
  
  Parameters
  ----------
  X : {array-like, sparse matrix} of shape (n_samples, n_features)
      The training input samples. Sparse matrices are accepted only if
      they are supported by the base estimator.
  
  y : array-like of shape (n_samples,)
      The target values (class labels in classification, real numbers in
      regression).
  
  max_samples : int or float, default=None
      Argument to use instead of self.max_samples.
  
  max_depth : int, default=None
      Override value used when constructing base estimator. Only
      supported if the base estimator has a max_depth parameter.
  
  sample_weight : array-like of shape (n_samples,), default=None
      Sample weights. If None, then samples are equally weighted.
      Note that this is supported only if the base estimator supports
      sample weighting.
  
  check_input : bool, default=True
      Override value used when fitting base estimator. Only supported
      if the base estimator has a check_input parameter for fit function.
  
  Returns
  -------
  self : object
      Fitted estimator.
docstr_tok: ["Build","a","Bagging","ensemble","of","estimators","from","the","training","set","(","X",",","y",")",".","Parameters","--","--","--","--","--","X",":","{","array-like",",","sparse","matrix","}","of","shape","(","n_samples",",","n_features",")","The","training","input","samples",".","Sparse","matrices","are","accepted","only","if","they","are","supported","by","the","base","estimator",".","y",":","array-like","of","shape","(","n_samples",",",")","The","target","values","(","class","labels","in","classification",",","real","numbers","in","regression",")",".","max_samples",":","int","or","float",",","default=None","Argument","to","use","instead","of","self.max_samples",".","max_depth",":","int",",","default=None","Override","value","used","when","constructing","base","estimator",".","Only","supported","if","the","base","estimator","has","a","max_depth","parameter",".","sample_weight",":","array-like","of","shape","(","n_samples",",",")",",","default=None","Sample","weights",".","If","None",",","then","samples","are","equally","weighted",".","Note","that","this","is","supported","only","if","the","base","estimator","supports","sample","weighting",".","check_input",":","bool",",","default=True","Override","value","used","when","fitting","base","estimator",".","Only","supported","if","the","base","estimator","has","a","check_input","parameter","for","fit","function",".","Returns","--","--","--","-","self",":","object","Fitted","estimator","."]
code: def _fit(
      self,
      X,
      y,
      max_samples=None,
      max_depth=None,
      sample_weight=None,
      check_input=True,
  ):
      """Build a Bagging ensemble of estimators from the training
         set (X, y).
  
      Parameters
      ----------
      X : {array-like, sparse matrix} of shape (n_samples, n_features)
          The training input samples. Sparse matrices are accepted only if
          they are supported by the base estimator.
  
      y : array-like of shape (n_samples,)
          The target values (class labels in classification, real numbers in
          regression).
  
      max_samples : int or float, default=None
          Argument to use instead of self.max_samples.
  
      max_depth : int, default=None
          Override value used when constructing base estimator. Only
          supported if the base estimator has a max_depth parameter.
  
      sample_weight : array-like of shape (n_samples,), default=None
          Sample weights. If None, then samples are equally weighted.
          Note that this is supported only if the base estimator supports
          sample weighting.
  
      check_input : bool, default=True
          Override value used when fitting base estimator. Only supported
          if the base estimator has a check_input parameter for fit function.
  
      Returns
      -------
      self : object
          Fitted estimator.
      """
      random_state = check_random_state(self.random_state)
  
      if sample_weight is not None:
          sample_weight = _check_sample_weight(
              sample_weight, X, dtype=None
          )
  
      # Remap output
      n_samples = X.shape[0]
      self._n_samples = n_samples
      y = self._validate_y(y)
  
      # Check parameters
      self._validate_estimator()
  
      if max_depth is not None:
          self.estimator_.max_depth = max_depth
  
      # Validate max_samples
      if max_samples is None:
          max_samples = self.max_samples
      elif not isinstance(max_samples, numbers.Integral):
          max_samples = int(max_samples * X.shape[0])
  
      if max_samples > X.shape[0]:
          raise ValueError("max_samples must be <= n_samples")
  
      # Store validated integer row sampling value
      self._max_samples = max_samples
  
      # Validate max_features
      if isinstance(self.max_features, numbers.Integral):
          max_features = self.max_features
      elif isinstance(self.max_features, float):
          max_features = int(self.max_features * self.n_features_in_)
  
      if max_features > self.n_features_in_:
          raise ValueError("max_features must be <= n_features")
  
      max_features = max(1, int(max_features))
  
      # Store validated integer feature sampling value
      self._max_features = max_features
  
      # Other checks
      if not self.bootstrap and self.oob_score:
          raise ValueError(
              "Out of bag estimation only available if bootstrap=True"
          )
  
      if self.warm_start and self.oob_score:
          raise ValueError(
              "Out of bag estimate only available if warm_start=False"
          )
  
      if hasattr(self, "oob_score_") and self.warm_start:
          del self.oob_score_
  
      if not self.warm_start or not hasattr(self, "estimators_"):
          # Free allocated memory, if any
          self.estimators_ = []
          self.estimators_features_ = []
  
      n_more_estimators = self.n_estimators - len(self.estimators_)
  
      if n_more_estimators < 0:
          raise ValueError(
              "n_estimators=%d must be larger or equal to "
              "len(estimators_)=%d when warm_start==True"
              % (self.n_estimators, len(self.estimators_))
          )
  
      elif n_more_estimators == 0:
          warn(
              "Warm-start fitting without increasing n_estimators does not "
              "fit new trees."
          )
          return self
  
      # Parallel loop
      n_jobs, n_estimators, starts = _partition_estimators(
          n_more_estimators, self.n_jobs
      )
      total_n_estimators = sum(n_estimators)
  
      # Advance random state to state after training
      # the first n_estimators
      if self.warm_start and len(self.estimators_) > 0:
          random_state.randint(MAX_INT, size=len(self.estimators_))
  
      seeds = random_state.randint(MAX_INT, size=n_more_estimators)
      self._seeds = seeds
  
      all_results = Parallel(
          n_jobs=n_jobs, verbose=self.verbose, **self._parallel_args()
      )(
          delayed(_parallel_build_estimators)(
              n_estimators[i],
              self,
              X,
              y,
              sample_weight,
              seeds[starts[i] : starts[i + 1]],
              total_n_estimators,
              verbose=self.verbose,
              check_input=check_input,
          )
          for i in range(n_jobs)
      )
  
      # Reduce
      self.estimators_ += list(
          itertools.chain.from_iterable(t[0] for t in all_results)
      )
      self.estimators_features_ += list(
          itertools.chain.from_iterable(t[1] for t in all_results)
      )
  
      if self.oob_score:
          self._set_oob_score(X, y)
  
      return self
  
imports: import itertools
  import numbers
  from abc import ABCMeta, abstractmethod
  from functools import partial
  from numbers import Integral
  from warnings import warn
  import numpy
  from ..base import ClassifierMixin, RegressorMixin, _fit_context
  from ..metrics import accuracy_score, r2_score
  from ..tree import DecisionTreeClassifier, DecisionTreeRegressor
  from ..utils import check_random_state, column_or_1d, indices_to_mask
  from ..utils._param_validation import HasMethods, Interval, RealNotInt, StrOptions
  from ..utils._tags import _safe_tags
  from ..utils.metaestimators import available_if
  from ..utils.multiclass import check_classification_targets
  from ..utils.parallel import Parallel, delayed
  from ..utils.random import sample_without_replacement
  from ..utils.validation import _check_sample_weight, check_is_fitted, has_fit_parameter
  from ._base import BaseEnsemble, _partition_estimators
label_desc: Use image node_id 4 for calling the BaseBagging obj's underlying member method code with example usage: obj._fit(X, y, max_samples, max_depth, sample_weight, check_input) and returns: self, self