class_docstr: A cudf based implementation of target encoding [1]_, which converts
  one or multiple categorical variables, 'Xs', with the average of
  corresponding values of the target variable, 'Y'. The input data is
  grouped by the columns `Xs` and the aggregated mean value of `Y` of
  each group is calculated to replace each value of `Xs`. Several
  optimizations are applied to prevent label leakage and parallelize
  the execution.
  
  Parameters
  ----------
  n_folds : int (default=4)
      Default number of folds for fitting training data. To prevent
      label leakage in `fit`, we split data into `n_folds` and
      encode one fold using the target variables of the remaining folds.
  smooth : int or float (default=0)
      Count of samples to smooth the encoding. 0 means no smoothing.
  seed : int (default=42)
      Random seed
  split_method : {'random', 'continuous', 'interleaved'},         (default='interleaved')
      Method to split train data into `n_folds`.
      'random': random split.
      'continuous': consecutive samples are grouped into one folds.
      'interleaved': samples are assign to each fold in a round robin way.
      'customize': customize splitting by providing a `fold_ids` array
      in `fit()` or `fit_transform()` functions.
  output_type : {'cupy', 'numpy', 'auto'}, default = 'auto'
      The data type of output. If 'auto', it matches input data.
  stat : {'mean','var','median'}, default = 'mean'
      The statistic used in encoding, mean, variance or median of the
      target.
  
  References
  ----------
  .. [1] https://maxhalford.github.io/blog/target-encoding/
  
  Examples
  --------
  Converting a categorical implementation to a numerical one
  
  >>> from cudf import DataFrame, Series
  >>> from cuml.preprocessing import TargetEncoder
  >>> train = DataFrame({'category': ['a', 'b', 'b', 'a'],
  ...                    'label': [1, 0, 1, 1]})
  >>> test = DataFrame({'category': ['a', 'c', 'b', 'a']})
  
  >>> encoder = TargetEncoder()
  >>> train_encoded = encoder.fit_transform(train.category, train.label)
  >>> test_encoded = encoder.transform(test.category)
  >>> print(train_encoded)
  [1. 1. 0. 1.]
  >>> print(test_encoded)
  [1.   0.75 0.5  1.  ]
code: def __init__(
      self,
      n_folds=4,
      smooth=0,
      seed=42,
      split_method="interleaved",
      output_type="auto",
      stat="mean",
  ):
      if smooth < 0:
          raise ValueError(f"smooth {smooth} is not zero or positive")
      if n_folds < 0 or not isinstance(n_folds, int):
          raise ValueError(
              "n_folds {} is not a positive integer".format(n_folds)
          )
      if output_type not in {"cupy", "numpy", "auto"}:
          msg = (
              "output_type should be either 'cupy'"
              " or 'numpy' or 'auto', "
              "got {0}.".format(output_type)
          )
          raise ValueError(msg)
      if stat not in {"mean", "var", "median"}:
          msg = (
              "stat should be 'mean', 'var' or 'median'." f"got {stat}."
          )
          raise ValueError(msg)
  
      if not isinstance(seed, int):
          raise ValueError("seed {} is not an integer".format(seed))
  
      if split_method not in {
          "random",
          "continuous",
          "interleaved",
          "customize",
      }:
          msg = (
              "split_method should be either 'random'"
              " or 'continuous' or 'interleaved', or 'customize'"
              "got {0}.".format(split_method)
          )
          raise ValueError(msg)
  
      self.n_folds = n_folds
      self.seed = seed
      self.smooth = smooth
      self.split_method = split_method
      self.y_col = "__TARGET__"
      self.y_col2 = "__TARGET__SQUARE__"
      self.x_col = "__FEA__"
      self.out_col = "__TARGET_ENCODE__"
      self.out_col2 = "__TARGET_ENCODE__SQUARE__"
      self.fold_col = "__FOLD__"
      self.id_col = "__INDEX__"
      self.train = None
      self.output_type = output_type
      self.stat = stat
  
imports: import warnings
  from cuml.common.exceptions import NotFittedError
  from cuml.internals.safe_imports import cpu_only_import
  from cuml.internals.safe_imports import gpu_only_import
label_desc: Use image node_id 1 to create a new TargetEncoder object  with example: obj = TargetEncoder(n_folds, smooth, seed, split_method, output_type, stat)