class_docstr: Base class for histogram-based gradient boosting estimators.
class_docstr_tok: ["Base","class","for","histogram-based","gradient","boosting","estimators","."]
docstr: Bin data X.
  
  If is_training_data, then fit the _bin_mapper attribute.
  Else, the binned data is converted to a C-contiguous array.
docstr_tok: ["Bin","data","X",".","If","is_training_data",",","then","fit","the","_bin_mapper","attribute",".","Else",",","the","binned","data","is","converted","to","a","C-contiguous","array","."]
code: def _bin_data(self, X, is_training_data):
      """Bin data X.
  
      If is_training_data, then fit the _bin_mapper attribute.
      Else, the binned data is converted to a C-contiguous array.
      """
  
      description = "training" if is_training_data else "validation"
      if self.verbose:
          print(
              "Binning {:.3f} GB of {} data: ".format(
                  X.nbytes / 1e9, description
              ),
              end="",
              flush=True,
          )
      tic = time()
      if is_training_data:
          X_binned = self._bin_mapper.fit_transform(
              X
          )  # F-aligned array
      else:
          X_binned = self._bin_mapper.transform(X)  # F-aligned array
          # We convert the array to C-contiguous since predicting is faster
          # with this layout (training is faster on F-arrays though)
          X_binned = np.ascontiguousarray(X_binned)
      toc = time()
      if self.verbose:
          duration = toc - tic
          print("{:.3f} s".format(duration))
  
      return X_binned
  
imports: import itertools
  from abc import ABC, abstractmethod
  from functools import partial
  from numbers import Integral, Real
  from timeit import default_timer
  import numpy
  from ..._loss.loss import _LOSSES, BaseLoss, HalfBinomialLoss, HalfGammaLoss, HalfMultinomialLoss, HalfPoissonLoss, PinballLoss
  from ...base import BaseEstimator, ClassifierMixin, RegressorMixin, _fit_context, is_classifier
  from ...metrics import check_scoring
  from ...model_selection import train_test_split
  from ...preprocessing import LabelEncoder
  from ...utils import check_random_state, compute_sample_weight, resample
  from ...utils._openmp_helpers import _openmp_effective_n_threads
  from ...utils._param_validation import Interval, RealNotInt, StrOptions
  from ...utils.multiclass import check_classification_targets
  from ...utils.validation import _check_monotonic_cst, _check_sample_weight, check_consistent_length, check_is_fitted
  from ._gradient_boosting import _update_raw_predictions
  from .binning import _BinMapper
  from .common import G_H_DTYPE, X_DTYPE, Y_DTYPE
  from .grower import TreeGrower
label_desc: Use image node_id 13 for calling the BaseHistGradientBoosting obj's underlying member method code with example usage: obj._bin_data(X, is_training_data) and returns: X_binned