class_docstr: Base class for stacking method.
class_docstr_tok: ["Base","class","for","stacking","method","."]
docstr: Concatenate the predictions of each first layer learner and
  possibly the input dataset `X`.
  
  If `X` is sparse and `self.passthrough` is False, the output of
  `transform` will be dense (the predictions). If `X` is sparse
  and `self.passthrough` is True, the output of `transform` will
  be sparse.
  
  This helper is in charge of ensuring the predictions are 2D arrays and
  it will drop one of the probability column when using probabilities
  in the binary case. Indeed, the p(y|c=0) = 1 - p(y|c=1)
  
  When `y` type is `"multilabel-indicator"`` and the method used is
  `predict_proba`, `preds` can be either a `ndarray` of shape
  `(n_samples, n_class)` or for some estimators a list of `ndarray`.
  This function will drop one of the probability column in this situation as well.
docstr_tok: ["Concatenate","the","predictions","of","each","first","layer","learner","and","possibly","the","input","dataset","`","X","`",".","If","`","X","`","is","sparse","and","`","self.passthrough","`","is","False",",","the","output","of","`","transform","`","will","be","dense","(","the","predictions",")",".","If","`","X","`","is","sparse","and","`","self.passthrough","`","is","True",",","the","output","of","`","transform","`","will","be","sparse",".","This","helper","is","in","charge","of","ensuring","the","predictions","are","2D","arrays","and","it","will","drop","one","of","the","probability","column","when","using","probabilities","in","the","binary","case",".","Indeed",",","the","p","(","y|c=0",")","=","1","-","p","(","y|c=1",")","When","`","y","`","type","is","`","``","multilabel-indicator","''","``","and","the","method","used","is","`","predict_proba","`",",","`","preds","`","can","be","either","a","`","ndarray","`","of","shape","`","(","n_samples",",","n_class",")","`","or","for","some","estimators","a","list","of","`","ndarray","`",".","This","function","will","drop","one","of","the","probability","column","in","this","situation","as","well","."]
code: def _concatenate_predictions(self, X, predictions):
      """Concatenate the predictions of each first layer learner and
      possibly the input dataset `X`.
  
      If `X` is sparse and `self.passthrough` is False, the output of
      `transform` will be dense (the predictions). If `X` is sparse
      and `self.passthrough` is True, the output of `transform` will
      be sparse.
  
      This helper is in charge of ensuring the predictions are 2D arrays and
      it will drop one of the probability column when using probabilities
      in the binary case. Indeed, the p(y|c=0) = 1 - p(y|c=1)
  
      When `y` type is `"multilabel-indicator"`` and the method used is
      `predict_proba`, `preds` can be either a `ndarray` of shape
      `(n_samples, n_class)` or for some estimators a list of `ndarray`.
      This function will drop one of the probability column in this situation as well.
      """
      X_meta = []
      for est_idx, preds in enumerate(predictions):
          if isinstance(preds, list):
              # `preds` is here a list of `n_targets` 2D ndarrays of
              # `n_classes` columns. The k-th column contains the
              # probabilities of the samples belonging the k-th class.
              #
              # Since those probabilities must sum to one for each sample,
              # we can work with probabilities of `n_classes - 1` classes.
              # Hence we drop the first column.
              for pred in preds:
                  X_meta.append(pred[:, 1:])
          elif preds.ndim == 1:
              # Some estimator return a 1D array for predictions
              # which must be 2-dimensional arrays.
              X_meta.append(preds.reshape(-1, 1))
          elif (
              self.stack_method_[est_idx] == "predict_proba"
              and len(self.classes_) == 2
          ):
              # Remove the first column when using probabilities in
              # binary classification because both features `preds` are perfectly
              # collinear.
              X_meta.append(preds[:, 1:])
          else:
              X_meta.append(preds)
  
      self._n_feature_outs = [pred.shape[1] for pred in X_meta]
      if self.passthrough:
          X_meta.append(X)
          if sparse.issparse(X):
              return sparse.hstack(X_meta, format=X.format)
  
      return np.hstack(X_meta)
  
imports: from abc import ABCMeta, abstractmethod
  from copy import deepcopy
  from numbers import Integral
  import numpy
  import scipy.sparse
  from ..base import ClassifierMixin, RegressorMixin, TransformerMixin, _fit_context, clone, is_classifier, is_regressor
  from ..exceptions import NotFittedError
  from ..linear_model import LogisticRegression, RidgeCV
  from ..model_selection import check_cv, cross_val_predict
  from ..preprocessing import LabelEncoder
  from ..utils import Bunch
  from ..utils._estimator_html_repr import _VisualBlock
  from ..utils._param_validation import HasMethods, StrOptions
  from ..utils.metadata_routing import _raise_for_unsupported_routing, _RoutingNotSupportedMixin
  from ..utils.metaestimators import available_if
  from ..utils.multiclass import check_classification_targets, type_of_target
  from ..utils.parallel import Parallel, delayed
  from ..utils.validation import _check_feature_names_in, _check_response_method, check_is_fitted, column_or_1d
  from ._base import _BaseHeterogeneousEnsemble, _fit_single_estimator
label_desc: Use image node_id 3 for calling the _BaseStacking obj's underlying member method code with example usage: obj._concatenate_predictions(X, predictions) and returns: np, sparse