class_docstr: StackingTransformer. Scikit-learn compatible API for stacking.
  
  Parameters
  ----------
  estimators : list of tuples, default None
      Base level estimators.
      If None then by default:
          DummyRegressor (predicts constant 5.5) - for regression task
          DummyClassifier (predicts constant 1) - for classification task
      You can use any sklearn-like estimators.
      Each tuple in the list contains arbitrary
          unique name and estimator object, e.g.:
      estimators = [('lr', LinearRegression()),
                    ('ridge', Ridge(random_state=0))]
  
      Note. According to sklearn convention for binary classification
          task with probabilities estimator must return probabilities
          for each class (i.e. two columns).
  
  regression : boolean, default True
      If True - perform stacking for regression task,
      if False - perform stacking for classification task
  
  transform_target : callable, default None
      Function to transform target variable.
      If None - transformation is not used.
      For example, for regression task (if target variable is skewed)
          you can use transformation like ``numpy.log1p``.
          Set ``transform_target=numpy.log1p``
      Usually you want to use respective backward transformation
          for prediction like ``numpy.expm1``.
          Set ``transform_pred=numpy.expm1``
      Caution! Some transformations may give inapplicable results.
          For example, if target variable contains zeros, numpy.log
          gives you -inf. In such case you can use appropriate
          transformation like ``numpy.log1p`` and respective
          backward transformation like ``numpy.expm1``
  
  transform_pred : callable, default None
      Function to transform prediction.
      If None - transformation is not used.
      If you use transformation for target variable (``transform_target``)
          like ``numpy.log1p``, then using ``transform_pred`` you can specify
          respective backward transformation like ``numpy.expm1``.
      Look at description of parameter ``transform_target``
  
  variant: str, default 'A'
      Possible values: 'A', 'B'.
      This parameter influences test set predictions only.
      Variant 'A' - predict test set in each fold and find mean (mode)
      Variant 'B' - fit on full train set and predict test set once
      See tutorial for details:
      https://github.com/vecxoz/vecstack/blob/master/             examples/00_stacking_concept_pictures_code.ipynb
  
  needs_proba: boolean, default False, meaningful only for classification
      Whether to predict probabilities (instead of class labels)
      in classification task.
      Ignored if ``regression=True``
  
  metric : callable, default None
      Evaluation metric (score function) which is used to calculate
      cross-validation scores.
      If None, then by default:
          sklearn.metrics.mean_absolute_error - for regression
          sklearn.metrics.accuracy_score - for classification
              with class labels
          sklearn.metrics.log_loss - for classification with probabilities
      You can use any appropriate sklearn metric or
          define your own metric like shown below:
  
      def your_metric(y_true, y_pred):
          # calculate
          return result
  
  n_folds : int, default 4
      Number of folds in cross-validation
  
  stratified : boolean, default False, meaningful only for classification
      If True - use stratified folds in cross-validation
      Ignored if ``regression=True``
  
  shuffle : boolean, default False
      Whether to perform a shuffle before cross-validation split
  
  random_state : int, default 0
      Random seed used to initiate fold split.
      Same seed and correspondingly same split is used for all estimators.
  
  verbose : int, default 0
      Level of verbosity.
      0 - show no messages
      1 - for each estimator show mean score
      2 - for each estimator show score for each fold and mean score
  
  
  Attributes
  ----------
  estimators_ : list
      List of base estimators (not fitted) passed by user (or default)
  n_estimators_ : int
      Number of base estimators passed by user (or default)
  n_classes_ : int
      Number of classes in classification task.
      ``None`` in regression task.
  models_A_ : list of lists
      List containing n_estimators lists. Each of which contains
      n_folds models (fitted estimators).
      In variant A this models are used to transform (predict)
          both train set and test set
      In variant B this models are used to transform (predict)
          train set only
  models_B_ : list or None
      List containing n_estimators models (fitted estimators).
      In variant A this attribute is None
      In variant B this models are used to transform (predict) test set
  metric_ : callable
      Metric passed by user (or default) which was used
      to compute cross-validation scores
  kf_ : KFold or StratifiedKFold object
      Initialized cross-validation object which was used to split train set
      during fitting
  scores_ : 2d numpy array of shape [n_estimators, n_folds]
      Scores for each fold for each estimator.
  mean_std_ : list of tuples
      Each tuple contains name, mean and std for each estimator.
  train_shape_ : tuple of ints
      Shape of training data
  n_train_examples_ : int
      Number of training examples
  n_features_: int
      Number of features
  train_footprint_ : list of tuples
      Train set footprint which is used to identify train set
      during transform (predict) phase.
      Each tuple containes 3 values: row index, column index, data value
  
  Examples
  --------
  >>> from sklearn.datasets import load_boston
  >>> from sklearn.model_selection import train_test_split
  >>> from sklearn.metrics import mean_absolute_error
  >>> from sklearn.ensemble import ExtraTreesRegressor, RandomForestRegressor
  >>> from xgboost import XGBRegressor
  >>> from vecstack import StackingTransformer
  >>>
  >>> # Load demo data
  >>> boston = load_boston()
  >>> X, y = boston.data, boston.target
  >>>
  >>> # Make train/test split
  >>> X_train, X_test, y_train, y_test = train_test_split(X, y,
                                                          test_size=0.2,
                                                          random_state=0)
  >>>
  >>> # Init 1st level estimators
  >>> estimators_L1 = [('et', ExtraTreesRegressor(random_state=0,
                                                  n_jobs=-1,
                                                  n_estimators=100,
                                                  max_depth=3)),
                       ('rf', RandomForestRegressor(random_state=0,
                                                    n_jobs=-1,
                                                    n_estimators=100,
                                                    max_depth=3)),
                       ('xgb', XGBRegressor(random_state=0,
                                            n_jobs=-1,
                                            learning_rate=0.1,
                                            n_estimators=100,
                                            max_depth=3))]
  >>> # Stacking
  >>> stack = StackingTransformer(estimators=estimators_L1,
                                  regression=True,
                                  shuffle=True,
                                  random_state=0,
                                  verbose=2)
  >>> stack = stack.fit(X_train, y_train)
  >>> S_train = stack.transform(X_train)
  >>> S_test = stack.transform(X_test)
  >>>
  >>> # Use 2nd level estimator to get final prediction
  >>> estimator_L2 = XGBRegressor(random_state=0,
                                  n_jobs=-1,
                                  learning_rate=0.1,
                                  n_estimators=100,
                                  max_depth=3)
  >>> estimator_L2 = estimator_L2.fit(S_train, y_train)
  >>> y_pred = estimator_L2.predict(S_test)
  >>>
  >>> # Final prediction score
  >>> print('Final score: [%.8f]' % mean_absolute_error(y_test, y_pred))
class_docstr_tok: ["StackingTransformer",".","Scikit-learn","compatible","API","for","stacking",".","Parameters","--","--","--","--","--","estimators",":","list","of","tuples",",","default","None","Base","level","estimators",".","If","None","then","by","default",":","DummyRegressor","(","predicts","constant","5.5",")","-","for","regression","task","DummyClassifier","(","predicts","constant","1",")","-","for","classification","task","You","can","use","any","sklearn-like","estimators",".","Each","tuple","in","the","list","contains","arbitrary","unique","name","and","estimator","object",",","e.g",".",":","estimators","=","[","(","'lr","'",",","LinearRegression","(",")",")",",","(","'ridge","'",",","Ridge","(","random_state=0",")",")","]","Note",".","According","to","sklearn","convention","for","binary","classification","task","with","probabilities","estimator","must","return","probabilities","for","each","class","(","i.e",".","two","columns",")",".","regression",":","boolean",",","default","True","If","True","-","perform","stacking","for","regression","task",",","if","False","-","perform","stacking","for","classification","task","transform_target",":","callable",",","default","None","Function","to","transform","target","variable",".","If","None","-","transformation","is","not","used",".","For","example",",","for","regression","task","(","if","target","variable","is","skewed",")","you","can","use","transformation","like","``","numpy.log1p","``",".","Set","``","transform_target=numpy.log1p","``","Usually","you","want","to","use","respective","backward","transformation","for","prediction","like","``","numpy.expm1","``",".","Set","``","transform_pred=numpy.expm1","``","Caution","!","Some","transformations","may","give","inapplicable","results",".","For","example",",","if","target","variable","contains","zeros",",","numpy.log","gives","you","-inf",".","In","such","case","you","can","use","appropriate","transformation","like","``","numpy.log1p","``","and","respective","backward","transformation","like","``","numpy.expm1","``","transform_pred",":","callable",",","default","None","Function","to","transform","prediction",".","If","None","-","transformation","is","not","used",".","If","you","use","transformation","for","target","variable","(","``","transform_target","``",")","like","``","numpy.log1p","``",",","then","using","``","transform_pred","``","you","can","specify","respective","backward","transformation","like","``","numpy.expm1","``",".","Look","at","description","of","parameter","``","transform_target","``","variant",":","str",",","default","'","A'","Possible","values",":","'","A","'",",","'","B","'",".","This","parameter","influences","test","set","predictions","only",".","Variant","'","A","'","-","predict","test","set","in","each","fold","and","find","mean","(","mode",")","Variant","'","B","'","-","fit","on","full","train","set","and","predict","test","set","once","See","tutorial","for","details",":","https",":","\/\/github.com\/vecxoz\/vecstack\/blob\/master\/","examples\/00_stacking_concept_pictures_code.ipynb","needs_proba",":","boolean",",","default","False",",","meaningful","only","for","classification","Whether","to","predict","probabilities","(","instead","of","class","labels",")","in","classification","task",".","Ignored","if","``","regression=True","``","metric",":","callable",",","default","None","Evaluation","metric","(","score","function",")","which","is","used","to","calculate","cross-validation","scores",".","If","None",",","then","by","default",":","sklearn.metrics.mean_absolute_error","-","for","regression","sklearn.metrics.accuracy_score","-","for","classification","with","class","labels","sklearn.metrics.log_loss","-","for","classification","with","probabilities","You","can","use","any","appropriate","sklearn","metric","or","define","your","own","metric","like","shown","below",":","def","your_metric","(","y_true",",","y_pred",")",":","#","calculate","return","result","n_folds",":","int",",","default","4","Number","of","folds","in","cross-validation","stratified",":","boolean",",","default","False",",","meaningful","only","for","classification","If","True","-","use","stratified","folds","in","cross-validation","Ignored","if","``","regression=True","``","shuffle",":","boolean",",","default","False","Whether","to","perform","a","shuffle","before","cross-validation","split","random_state",":","int",",","default","0","Random","seed","used","to","initiate","fold","split",".","Same","seed","and","correspondingly","same","split","is","used","for","all","estimators",".","verbose",":","int",",","default","0","Level","of","verbosity",".","0","-","show","no","messages","1","-","for","each","estimator","show","mean","score","2","-","for","each","estimator","show","score","for","each","fold","and","mean","score","Attributes","--","--","--","--","--","estimators_",":","list","List","of","base","estimators","(","not","fitted",")","passed","by","user","(","or","default",")","n_estimators_",":","int","Number","of","base","estimators","passed","by","user","(","or","default",")","n_classes_",":","int","Number","of","classes","in","classification","task",".","``","None","``","in","regression","task",".","models_A_",":","list","of","lists","List","containing","n_estimators","lists",".","Each","of","which","contains","n_folds","models","(","fitted","estimators",")",".","In","variant","A","this","models","are","used","to","transform","(","predict",")","both","train","set","and","test","set","In","variant","B","this","models","are","used","to","transform","(","predict",")","train","set","only","models_B_",":","list","or","None","List","containing","n_estimators","models","(","fitted","estimators",")",".","In","variant","A","this","attribute","is","None","In","variant","B","this","models","are","used","to","transform","(","predict",")","test","set","metric_",":","callable","Metric","passed","by","user","(","or","default",")","which","was","used","to","compute","cross-validation","scores","kf_",":","KFold","or","StratifiedKFold","object","Initialized","cross-validation","object","which","was","used","to","split","train","set","during","fitting","scores_",":","2d","numpy","array","of","shape","[","n_estimators",",","n_folds","]","Scores","for","each","fold","for","each","estimator",".","mean_std_",":","list","of","tuples","Each","tuple","contains","name",",","mean","and","std","for","each","estimator",".","train_shape_",":","tuple","of","ints","Shape","of","training","data","n_train_examples_",":","int","Number","of","training","examples","n_features_",":","int","Number","of","features","train_footprint_",":","list","of","tuples","Train","set","footprint","which","is","used","to","identify","train","set","during","transform","(","predict",")","phase",".","Each","tuple","containes","3","values",":","row","index",",","column","index",",","data","value","Examples","--","--","--","--",">",">",">","from","sklearn.datasets","import","load_boston",">",">",">","from","sklearn.model_selection","import","train_test_split",">",">",">","from","sklearn.metrics","import","mean_absolute_error",">",">",">","from","sklearn.ensemble","import","ExtraTreesRegressor",",","RandomForestRegressor",">",">",">","from","xgboost","import","XGBRegressor",">",">",">","from","vecstack","import","StackingTransformer",">",">",">",">",">",">","#","Load","demo","data",">",">",">","boston","=","load_boston","(",")",">",">",">","X",",","y","=","boston.data",",","boston.target",">",">",">",">",">",">","#","Make","train\/test","split",">",">",">","X_train",",","X_test",",","y_train",",","y_test","=","train_test_split","(","X",",","y",",","test_size=0.2",",","random_state=0",")",">",">",">",">",">",">","#","Init","1st","level","estimators",">",">",">","estimators_L1","=","[","(","'et","'",",","ExtraTreesRegressor","(","random_state=0",",","n_jobs=-1",",","n_estimators=100",",","max_depth=3",")",")",",","(","'rf","'",",","RandomForestRegressor","(","random_state=0",",","n_jobs=-1",",","n_estimators=100",",","max_depth=3",")",")",",","(","'xgb","'",",","XGBRegressor","(","random_state=0",",","n_jobs=-1",",","learning_rate=0.1",",","n_estimators=100",",","max_depth=3",")",")","]",">",">",">","#","Stacking",">",">",">","stack","=","StackingTransformer","(","estimators=estimators_L1",",","regression=True",",","shuffle=True",",","random_state=0",",","verbose=2",")",">",">",">","stack","=","stack.fit","(","X_train",",","y_train",")",">",">",">","S_train","=","stack.transform","(","X_train",")",">",">",">","S_test","=","stack.transform","(","X_test",")",">",">",">",">",">",">","#","Use","2nd","level","estimator","to","get","final","prediction",">",">",">","estimator_L2","=","XGBRegressor","(","random_state=0",",","n_jobs=-1",",","learning_rate=0.1",",","n_estimators=100",",","max_depth=3",")",">",">",">","estimator_L2","=","estimator_L2.fit","(","S_train",",","y_train",")",">",">",">","y_pred","=","estimator_L2.predict","(","S_test",")",">",">",">",">",">",">","#","Final","prediction","score",">",">",">","print","(","'Final","score",":","[","%",".8f","]","'","%","mean_absolute_error","(","y_test",",","y_pred",")",")"]
docstr: Transform (predict) given data set.
  If ``X`` is train set:
      for each estimator return out-of-fold predictions (OOF).
  If ``X`` is any other set:
      variant A: for each estimator return mean (mode) of predictions
          made in each fold
      variant B: for each estimator return single prediction
  
  Parameters
  ----------
  X : 2d numpy array or sparse matrix of shape [n_samples, n_features]
      Input data
  
  is_train_set : boolean, default None
      Fallback parameter. In general case
          should not be used (should be None).
      Gives ability to explicitly specify that given dataset
          is train set or other set.
  
  Returns
  -------
  X_transformed : 2d numpy array of shape [n_samples, n_estimators] or
                  [n_samples, n_estimators * n_classes]
      Out-of-fold predictions (OOF) for train set.
      Regular or bagged predictions for any other set.
      This is stacked features for next level.
docstr_tok: ["Transform","(","predict",")","given","data","set",".","If","``","X","``","is","train","set",":","for","each","estimator","return","out-of-fold","predictions","(","OOF",")",".","If","``","X","``","is","any","other","set",":","variant","A",":","for","each","estimator","return","mean","(","mode",")","of","predictions","made","in","each","fold","variant","B",":","for","each","estimator","return","single","prediction","Parameters","--","--","--","--","--","X",":","2d","numpy","array","or","sparse","matrix","of","shape","[","n_samples",",","n_features","]","Input","data","is_train_set",":","boolean",",","default","None","Fallback","parameter",".","In","general","case","should","not","be","used","(","should","be","None",")",".","Gives","ability","to","explicitly","specify","that","given","dataset","is","train","set","or","other","set",".","Returns","--","--","--","-","X_transformed",":","2d","numpy","array","of","shape","[","n_samples",",","n_estimators","]","or","[","n_samples",",","n_estimators","*","n_classes","]","Out-of-fold","predictions","(","OOF",")","for","train","set",".","Regular","or","bagged","predictions","for","any","other","set",".","This","is","stacked","features","for","next","level","."]
code: def transform(self, X, is_train_set=None):
      """Transform (predict) given data set.
      If ``X`` is train set:
          for each estimator return out-of-fold predictions (OOF).
      If ``X`` is any other set:
          variant A: for each estimator return mean (mode) of predictions
              made in each fold
          variant B: for each estimator return single prediction
  
      Parameters
      ----------
      X : 2d numpy array or sparse matrix of shape [n_samples, n_features]
          Input data
  
      is_train_set : boolean, default None
          Fallback parameter. In general case
              should not be used (should be None).
          Gives ability to explicitly specify that given dataset
              is train set or other set.
  
      Returns
      -------
      X_transformed : 2d numpy array of shape [n_samples, n_estimators] or
                      [n_samples, n_estimators * n_classes]
          Out-of-fold predictions (OOF) for train set.
          Regular or bagged predictions for any other set.
          This is stacked features for next level.
      """
      # Check if fitted
      check_is_fitted(self, ["models_A_"])
  
      # Input validation
      # ``check_estimator`` does not allow ``force_all_finite=False``
      X = check_array(X, accept_sparse=["csr"], force_all_finite=True)
  
      # *********************************************************************
      # Fitted StackingTransformer instance is bound to train set used for fitting.
      # So during transformation we have different actions for train set
      # and all other sets
      # *********************************************************************
  
      if is_train_set is None:
          is_train_set = self._check_identity(X)
  
      # Print
      if self.verbose > 0:
          if is_train_set:
              print("Train set was detected.")
          print("Transforming...\n")
  
      # *********************************************************************
      # Transform train set
      # *********************************************************************
      if is_train_set:
          # In case if user directly tells that it is train set but shape is different
          if self.train_shape_ != X.shape:
              raise ValueError(
                  "Train set must have the same shape "
                  "in order to be transformed."
              )
  
          # Create empty numpy array for train predictions (OOF)
          S_train = np.zeros(
              (
                  X.shape[0],
                  self.n_estimators_ * self.n_classes_implicit_,
              )
          )
  
          # -----------------------------------------------------------------
          # MAIN TRANSFORM (PREDICT) PROCEDURE for train set
          # -----------------------------------------------------------------
          # Loop across estimators
          # -----------------------------------------------------------------
          for estimator_counter, (name, estimator) in enumerate(
              self.estimators_
          ):
              if self.verbose > 0:
                  estimator_str = "estimator %2d: [%s: %s]" % (
                      estimator_counter,
                      name,
                      estimator.__class__.__name__,
                  )
                  print(estimator_str)
  
              # -------------------------------------------------------------
              # Loop across folds
              # -------------------------------------------------------------
              for fold_counter, (tr_index, te_index) in enumerate(
                  self.kf_.split(X, self._y_)
              ):
                  # Split data
                  # X_tr = X[tr_index]
                  X_te = X[te_index]
  
                  # Predict out-of-fold part of train set
                  if "predict_proba" == self.action_:
                      col_slice_estimator = slice(
                          estimator_counter * self.n_classes_implicit_,
                          estimator_counter * self.n_classes_implicit_
                          + self.n_classes_implicit_,
                      )
                  else:
                      col_slice_estimator = estimator_counter
                  S_train[
                      te_index, col_slice_estimator
                  ] = self._estimator_action(
                      self.models_A_[estimator_counter][fold_counter],
                      None,
                      None,
                      X_te,
                      action=self.action_,
                      transform=self.transform_pred,
                  )
                  # Print
                  if self.verbose > 1:
                      fold_str = (
                          "    model from fold %2d: done" % fold_counter
                      )
                      print(fold_str)
  
              if self.verbose > 1:
                  sep_str = "    ----"
                  print(sep_str)
  
              if self.verbose > 0:
                  done_str = "    DONE\n"
                  print(done_str)
  
          # -----------------------------------------------------------------
          # Cast class labels to int
          # -----------------------------------------------------------------
          if not self.regression and not self.needs_proba:
              S_train = S_train.astype(int)
  
          # Return transformed data (OOF)
          return S_train  # X_transformed
  
      # *********************************************************************
      # Transform any other set
      # *********************************************************************
      else:
          # Check n_features
          if X.shape[1] != self.n_features_:
              raise ValueError("Inconsistent number of features.")
  
          # Create empty numpy array for test predictions
          S_test = np.zeros(
              (
                  X.shape[0],
                  self.n_estimators_ * self.n_classes_implicit_,
              )
          )
  
          # ---------------------------------------------------------------------
          # MAIN TRANSFORM (PREDICT) PROCEDURE for any other set
          # -----------------------------------------------------------------
          # Loop across estimators
          # -----------------------------------------------------------------
          for estimator_counter, (name, estimator) in enumerate(
              self.estimators_
          ):
              if self.verbose > 0:
                  estimator_str = "estimator %2d: [%s: %s]" % (
                      estimator_counter,
                      name,
                      estimator.__class__.__name__,
                  )
                  print(estimator_str)
              # -------------------------------------------------------------
              # Variant A
              # -------------------------------------------------------------
              if self.variant in ["A"]:
                  # Create empty numpy array, which will contain temporary predictions
                  # for test set made in each fold
                  S_test_temp = np.zeros(
                      (
                          X.shape[0],
                          self.n_folds * self.n_classes_implicit_,
                      )
                  )
                  # ---------------------------------------------------------
                  # Loop across fitted models (it is the same as loop across folds)
                  # ---------------------------------------------------------
                  for fold_counter, model in enumerate(
                      self.models_A_[estimator_counter]
                  ):
                      # Predict test set in each fold
                      if "predict_proba" == self.action_:
                          col_slice_fold = slice(
                              fold_counter * self.n_classes_implicit_,
                              fold_counter * self.n_classes_implicit_
                              + self.n_classes_implicit_,
                          )
                      else:
                          col_slice_fold = fold_counter
                      S_test_temp[
                          :, col_slice_fold
                      ] = self._estimator_action(
                          model,
                          None,
                          None,
                          X,
                          action=self.action_,
                          transform=self.transform_pred,
                      )
                      # Print
                      if self.verbose > 1:
                          fold_str = (
                              "    model from fold %2d: done"
                              % fold_counter
                          )
                          print(fold_str)
  
                  if self.verbose > 1:
                      sep_str = "    ----"
                      print(sep_str)
  
                  # ---------------------------------------------------------
                  # Compute mean or mode (majority voting) of predictions for test set
                  # ---------------------------------------------------------
                  if "predict_proba" == self.action_:
                      # Here we copute means of probabilirties for each class
                      for class_id in range(self.n_classes_implicit_):
                          S_test[
                              :,
                              estimator_counter
                              * self.n_classes_implicit_
                              + class_id,
                          ] = np.mean(
                              S_test_temp[
                                  :,
                                  class_id :: self.n_classes_implicit_,
                              ],
                              axis=1,
                          )
                  else:
                      if self.regression:
                          S_test[:, estimator_counter] = np.mean(
                              S_test_temp, axis=1
                          )
                      else:
                          S_test[:, estimator_counter] = st.mode(
                              S_test_temp, axis=1
                          )[0].ravel()
  
                  if self.verbose > 0:
                      done_str = "    DONE\n"
                      print(done_str)
  
              # -------------------------------------------------------------
              # Variant B
              # -------------------------------------------------------------
              else:
                  if "predict_proba" == self.action_:
                      col_slice_estimator = slice(
                          estimator_counter * self.n_classes_implicit_,
                          estimator_counter * self.n_classes_implicit_
                          + self.n_classes_implicit_,
                      )
                  else:
                      col_slice_estimator = estimator_counter
                  S_test[
                      :, col_slice_estimator
                  ] = self._estimator_action(
                      self.models_B_[estimator_counter],
                      None,
                      None,
                      X,
                      action=self.action_,
                      transform=self.transform_pred,
                  )
  
                  if self.verbose > 0:
                      done_str = "    DONE\n"
                      print(done_str)
  
          # ---------------------------------------------------------------------
          # Cast class labels to int
          # ---------------------------------------------------------------------
          if not self.regression and not self.needs_proba:
              S_test = S_test.astype(int)
  
          return S_test
  
imports: from __future__ import print_function
  from __future__ import division
  import warnings
  import numpy
  import scipy.stats
  from sklearn.base import BaseEstimator
  from sklearn.base import TransformerMixin
  from sklearn.base import clone
  from sklearn.dummy import DummyClassifier
  from sklearn.dummy import DummyRegressor
  from sklearn.utils.validation import check_X_y
  from sklearn.utils.validation import check_array
  from sklearn.utils.validation import check_is_fitted
  from sklearn.utils.validation import has_fit_parameter
  from sklearn.model_selection import KFold
  from sklearn.model_selection import StratifiedKFold
  from sklearn.metrics import mean_absolute_error
  from sklearn.metrics import accuracy_score
  from sklearn.metrics import log_loss
  from sklearn.metrics import mean_squared_error
label_desc: Use image node_id 4 for calling the StackingTransformer obj's underlying member method code with example usage: obj.transform(X, is_train_set) and returns: S_train, S_test