class_docstr: A stacking classifier.
  
  A stacking classifier is a classifier that uses the predictions of
  several first layer estimators (generated with a cross validation method)
  for a second layer estimator.
  
  Parameters
  ----------
  base_estimators : list, default = [Classifier(strategy="LightGBM"), Classifier(strategy="RandomForest"),Classifier(strategy="ExtraTrees")]
      List of estimators to fit in the first level using a cross validation.
  
  level_estimator : object, default = LogisticRegression()
      The estimator used in second and last level.
  
  n_folds : int, default = 5
      Number of folds used to generate the meta features for the training set
  
  copy : bool, default = False
      If true, meta features are added to the original dataset
  
  drop_first : bool, default = True
      If True, each estimator output n_classes-1 probabilities
  
  random_state : None or int or RandomState. default = 1
      Pseudo-random number generator state used for shuffling. If None, use
      default numpy RNG for shuffling.
  
  verbose : bool, default = True
      Verbose mode.
class_docstr_tok: ["A","stacking","classifier",".","A","stacking","classifier","is","a","classifier","that","uses","the","predictions","of","several","first","layer","estimators","(","generated","with","a","cross","validation","method",")","for","a","second","layer","estimator",".","Parameters","--","--","--","--","--","base_estimators",":","list",",","default","=","[","Classifier","(","strategy=","''","LightGBM","''",")",",","Classifier","(","strategy=","''","RandomForest","''",")",",","Classifier","(","strategy=","''","ExtraTrees","''",")","]","List","of","estimators","to","fit","in","the","first","level","using","a","cross","validation",".","level_estimator",":","object",",","default","=","LogisticRegression","(",")","The","estimator","used","in","second","and","last","level",".","n_folds",":","int",",","default","=","5","Number","of","folds","used","to","generate","the","meta","features","for","the","training","set","copy",":","bool",",","default","=","False","If","true",",","meta","features","are","added","to","the","original","dataset","drop_first",":","bool",",","default","=","True","If","True",",","each","estimator","output","n_classes-1","probabilities","random_state",":","None","or","int","or","RandomState",".","default","=","1","Pseudo-random","number","generator","state","used","for","shuffling",".","If","None",",","use","default","numpy","RNG","for","shuffling",".","verbose",":","bool",",","default","=","True","Verbose","mode","."]
docstr: Evaluates the target by cross-validation
  
  Parameters
  ----------
  estimator : estimator object implementing 'fit'
      The object to use to fit the data.
  
  df : pandas DataFrame
      The data to fit.
  
  y : pandas Serie
      The target variable to try to predict in the case of
      supervised learning.
  
  cv : a STRATIFIED cross-validation generator
  
  
  Returns
  -------
  y_pred : array-like of shape = (n_samples, n_classes)
      The predicted class probabilities for X.
docstr_tok: ["Evaluates","the","target","by","cross-validation","Parameters","--","--","--","--","--","estimator",":","estimator","object","implementing","'fit'","The","object","to","use","to","fit","the","data",".","df",":","pandas","DataFrame","The","data","to","fit",".","y",":","pandas","Serie","The","target","variable","to","try","to","predict","in","the","case","of","supervised","learning",".","cv",":","a","STRATIFIED","cross-validation","generator","Returns","--","--","--","-","y_pred",":","array-like","of","shape","=","(","n_samples",",","n_classes",")","The","predicted","class","probabilities","for","X","."]
code: def __cross_val_predict_proba(self, estimator, df, y, cv):
      """Evaluates the target by cross-validation
  
      Parameters
      ----------
      estimator : estimator object implementing 'fit'
          The object to use to fit the data.
  
      df : pandas DataFrame
          The data to fit.
  
      y : pandas Serie
          The target variable to try to predict in the case of
          supervised learning.
  
      cv : a STRATIFIED cross-validation generator
  
  
      Returns
      -------
      y_pred : array-like of shape = (n_samples, n_classes)
          The predicted class probabilities for X.
      """
  
      classes = y.value_counts()
      classes_to_drop = classes[classes < 2].index
      indexes_to_drop = y[y.apply(lambda x: x in classes_to_drop)].index
  
      y_pred = np.zeros((len(y), len(classes) - len(classes_to_drop)))
  
      for train_index, test_index in cv.split(df, y):
          # defining train and validation sets for each fold
          df_train, df_test = df.iloc[train_index], df.iloc[test_index]
          y_train = y.iloc[train_index]
  
          try:
              df_train = df_train.drop(indexes_to_drop)
              y_train = y_train.drop(indexes_to_drop)
  
          except Exception:
              pass
  
          # learning the model
          estimator.fit(df_train, y_train)
  
          # predicting the probability
          y_pred[test_index] = estimator.predict_proba(df_test)[:,]
  
      return y_pred
  
file_path: MLBox/mlbox/model/classification/stacking_classifier.py
imports: import numpy
  import pandas
  from sklearn.linear_model import LogisticRegression
  from sklearn.model_selection import StratifiedKFold
  from copy import copy
  from .classifier import Classifier
  import warnings
label_desc: Use image node_id 4 for calling the StackingClassifier obj's underlying member method code with example usage: obj.__cross_val_predict_proba(estimator, df, y, cv) and returns: y_pred