class_docstr: Сlass for storing, cleaning and processing your dataset
class_docstr_tok: ["\u0421lass","for","storing",",","cleaning","and","processing","your","dataset"]
docstr: Description of __init__
  
  Args:
      X_train=None (undefined): dataset
      y_train=None (undefined): y
      X_test=None (undefined): dataset
      y_test=None (undefined): y
      cat_features=None (list or None):
      clean_and_encod_data=True (undefined):
      cat_encoder_names=None (list or None):
      clean_nan=True (undefined):
      num_generator_features=True (undefined):
      group_generator_features=True (undefined):
      target_enc_cat_features=True (undefined)
      random_state=42 (undefined):
      verbose = 1 (undefined)
docstr_tok: ["Description","of","__init__","Args",":","X_train=None","(","undefined",")",":","dataset","y_train=None","(","undefined",")",":","y","X_test=None","(","undefined",")",":","dataset","y_test=None","(","undefined",")",":","y","cat_features=None","(","list","or","None",")",":","clean_and_encod_data=True","(","undefined",")",":","cat_encoder_names=None","(","list","or","None",")",":","clean_nan=True","(","undefined",")",":","num_generator_features=True","(","undefined",")",":","group_generator_features=True","(","undefined",")",":","target_enc_cat_features=True","(","undefined",")","random_state=42","(","undefined",")",":","verbose","=","1","(","undefined",")"]
code: def __init__(
      self,
      X_train=None,
      y_train=None,
      X_test=None,
      y_test=None,
      cat_features=None,
      clean_and_encod_data=True,
      cat_encoder_names=None,
      clean_nan=True,
      num_generator_features=True,
      group_generator_features=True,
      target_enc_cat_features=True,
      normalization=True,
      random_state=42,
      verbose=1,
  ):
      """
      Description of __init__
  
      Args:
          X_train=None (undefined): dataset
          y_train=None (undefined): y
          X_test=None (undefined): dataset
          y_test=None (undefined): y
          cat_features=None (list or None):
          clean_and_encod_data=True (undefined):
          cat_encoder_names=None (list or None):
          clean_nan=True (undefined):
          num_generator_features=True (undefined):
          group_generator_features=True (undefined):
          target_enc_cat_features=True (undefined)
          random_state=42 (undefined):
          verbose = 1 (undefined)
      """
      self.random_state = random_state
  
      self.X_train = None
      self.y_train = None
      self.X_test = None
      self.y_test = None
      self.X_train_predicts = None
      self.X_test_predicts = None
      self.cat_features = None
  
      # Encoders
      self.cat_encoders_names = settings.cat_encoders_names
      self.target_encoders_names = settings.target_encoders_names
  
      self.cat_encoder_names = cat_encoder_names
      self.cat_encoder_names_list = list(
          self.cat_encoders_names.keys()
      ) + list(self.target_encoders_names.keys())
      self.target_encoders_names_list = list(
          self.target_encoders_names.keys()
      )
  
      # check X_train, y_train, X_test
      if self.check_data_format(X_train):
          if type(X_train) == dask.dataframe.core.DataFrame:
              self.X_train_source = X_train.compute()
          else:
              self.X_train_source = pd.DataFrame(X_train)
          self.X_train_source = remove_duplicate_cols_in_dataset(
              self.X_train_source
          )
      if X_test is not None:
          if self.check_data_format(X_test):
              if type(X_test) == dask.dataframe.core.DataFrame:
                  self.X_test_source = X_test.compute()
              else:
                  self.X_test_source = pd.DataFrame(X_test)
              self.X_test_source = remove_duplicate_cols_in_dataset(
                  self.X_test_source
              )
  
      ### There is a chance for an error in this - so worth watching!
      if y_train is not None:
          le = LabelEncoder()
          if self.check_data_format(y_train):
              if settings.multi_label:
                  ### if the model is mult-Label, don't transform it since it won't work
                  self.y_train_source = y_train
              else:
                  if not isinstance(y_train, pd.DataFrame):
                      if (
                          y_train.dtype == "object"
                          or str(y_train.dtype) == "category"
                      ):
                          self.y_train_source = le.fit_transform(
                              y_train
                          )
                      else:
                          if (
                              settings.modeltype
                              == "Multi_Classification"
                          ):
                              rare_class = find_rare_class(y_train)
                              if rare_class != 0:
                                  ### if the rare class is not zero, then transform it using Label Encoder
                                  y_train = le.fit_transform(y_train)
                          self.y_train_source = copy.deepcopy(y_train)
                  else:
                      print(
                          "Error: y_train should be a series. Skipping target encoding for dataset..."
                      )
                      target_enc_cat_features = False
          else:
              if settings.multi_label:
                  self.y_train_source = pd.DataFrame(y_train)
              else:
                  if (
                      y_train.dtype == "object"
                      or str(y_train.dtype) == "category"
                  ):
                      self.y_train_source = le.fit_transform(
                          pd.DataFrame(y_train)
                      )
                  else:
                      self.y_train_source = copy.deepcopy(y_train)
      else:
          print("No target data found!")
          return
  
      if y_test is not None:
          self.y_test = y_test
  
      if verbose > 0:
          print("Source X_train shape: ", self.X_train_source.shape)
          if not X_test is None:
              print("| Source X_test shape: ", self.X_test_source.shape)
          print("#" * 50)
  
      # add categorical features in DataBunch
      if cat_features is None:
          self.cat_features = self.auto_detect_cat_features(
              self.X_train_source
          )
          if verbose > 0:
              print(
                  "Auto detect cat features: ", len(self.cat_features)
              )
  
      else:
          self.cat_features = list(cat_features)
  
      # preproc_data in DataBunch
      if clean_and_encod_data:
          if verbose > 0:
              print(
                  "> Start preprocessing with %d variables"
                  % self.X_train_source.shape[1]
              )
          self.X_train, self.X_test = self.preproc_data(
              self.X_train_source,
              self.X_test_source,
              self.y_train_source,
              cat_features=self.cat_features,
              cat_encoder_names=cat_encoder_names,
              clean_nan=clean_nan,
              num_generator_features=num_generator_features,
              group_generator_features=group_generator_features,
              target_enc_cat_features=target_enc_cat_features,
              normalization=normalization,
              verbose=verbose,
          )
      else:
          self.X_train, self.X_test = X_train, X_test
  
imports: import pandas
  import numpy
  from itertools import combinations
  from sklearn.preprocessing import StandardScaler
  from category_encoders import HashingEncoder, SumEncoder, PolynomialEncoder, BackwardDifferenceEncoder
  from category_encoders import OneHotEncoder, HelmertEncoder, OrdinalEncoder, CountEncoder, BaseNEncoder
  from category_encoders import TargetEncoder, CatBoostEncoder, WOEEncoder, JamesSteinEncoder
  from category_encoders.glmm import GLMMEncoder
  from sklearn.preprocessing import LabelEncoder
  from category_encoders.wrapper import PolynomialWrapper
  from .encoders import FrequencyEncoder
  from .None import settings
  import pdb
  import copy
  import dask
  import dask.dataframe
label_desc: Use image node_id 1 to create a new DataBunch object from inherited base classes: object with example: obj = DataBunch(X_train, y_train, X_test, y_test, cat_features, clean_and_encod_data, cat_encoder_names, clean_nan, num_generator_features, group_generator_features, target_enc_cat_features, normalization, random_state, verbose)