class_docstr: Abstract base class for Gradient Boosting.
class_docstr_tok: ["Abstract","base","class","for","Gradient","Boosting","."]
docstr: Apply trees in the ensemble to X, return leaf indices.
  
  .. versionadded:: 0.17
  
  Parameters
  ----------
  X : {array-like, sparse matrix} of shape (n_samples, n_features)
      The input samples. Internally, its dtype will be converted to
      ``dtype=np.float32``. If a sparse matrix is provided, it will
      be converted to a sparse ``csr_matrix``.
  
  Returns
  -------
  X_leaves : array-like of shape (n_samples, n_estimators, n_classes)
      For each datapoint x in X and for each tree in the ensemble,
      return the index of the leaf x ends up in each estimator.
      In the case of binary classification n_classes is 1.
code: def apply(self, X):
      """Apply trees in the ensemble to X, return leaf indices.
  
      .. versionadded:: 0.17
  
      Parameters
      ----------
      X : {array-like, sparse matrix} of shape (n_samples, n_features)
          The input samples. Internally, its dtype will be converted to
          ``dtype=np.float32``. If a sparse matrix is provided, it will
          be converted to a sparse ``csr_matrix``.
  
      Returns
      -------
      X_leaves : array-like of shape (n_samples, n_estimators, n_classes)
          For each datapoint x in X and for each tree in the ensemble,
          return the index of the leaf x ends up in each estimator.
          In the case of binary classification n_classes is 1.
      """
  
      self._check_initialized()
      X = self.estimators_[0, 0]._validate_X_predict(
          X, check_input=True
      )
  
      # n_classes will be equal to 1 in the binary classification or the
      # regression case.
      n_estimators, n_classes = self.estimators_.shape
      leaves = np.zeros((X.shape[0], n_estimators, n_classes))
  
      for i in range(n_estimators):
          for j in range(n_classes):
              estimator = self.estimators_[i, j]
              leaves[:, i, j] = estimator.apply(X, check_input=False)
  
      return leaves
  
imports: import warnings
  from abc import ABCMeta, abstractmethod
  from numbers import Integral, Real
  from time import time
  import numpy
  from scipy.sparse import csc_matrix, csr_matrix, issparse
  from ..base import ClassifierMixin, RegressorMixin, _fit_context, is_classifier
  from ..exceptions import NotFittedError
  from ..model_selection import train_test_split
  from ..tree import DecisionTreeRegressor
  from ..tree._tree import DOUBLE, DTYPE
  from ..utils import check_array, check_random_state, column_or_1d
  from ..utils._param_validation import HasMethods, Interval, StrOptions
  from ..utils.multiclass import check_classification_targets
  from ..utils.validation import _check_sample_weight, check_is_fitted
  from .None import _gb_losses
  from ._base import BaseEnsemble
  from ._gradient_boosting import _random_sample_mask, predict_stage, predict_stages
label_desc: Use image node_id 18 for calling the BaseGradientBoosting obj's underlying member method code with example usage: obj.apply(X) and returns: leaves