class_docstr: Encode categorical features as a one-hot numeric array.
  The input to this estimator should be a :py:class:`cuDF.DataFrame` or a
  :py:class:`cupy.ndarray`, denoting the unique values taken on by categorical
  (discrete) features.  The features are encoded using a one-hot (aka 'one-of-K' or
  'dummy') encoding scheme. This creates a binary column for each category and returns
  a sparse matrix or dense array (depending on the ``sparse`` parameter).
  
  By default, the encoder derives the categories based on the unique values
  in each feature. Alternatively, you can also specify the `categories`
  manually.
  
  .. note:: a one-hot encoding of y labels should use a LabelBinarizer
      instead.
  
  Parameters
  ----------
  categories : 'auto' an cupy.ndarray or a cudf.DataFrame, default='auto'
               Categories (unique values) per feature:
  
      - 'auto' : Determine categories automatically from the training data.
  
      - DataFrame/ndarray : ``categories[col]`` holds the categories expected
        in the feature col.
  
  drop : 'first', None, a dict or a list, default=None
      Specifies a methodology to use to drop one of the categories per
      feature. This is useful in situations where perfectly collinear
      features cause problems, such as when feeding the resulting data
      into a neural network or an unregularized regression.
  
      - None : retain all features (the default).
  
      - 'first' : drop the first category in each feature. If only one
        category is present, the feature will be dropped entirely.
  
      - dict/list : ``drop[col]`` is the category in feature col that
        should be dropped.
  
  sparse : bool, default=True
      This feature is not fully supported by cupy
      yet, causing incorrect values when computing one hot encodings.
      See https://github.com/cupy/cupy/issues/3223
  dtype : number type, default=np.float
      Desired datatype of transform's output.
  handle_unknown : {'error', 'ignore'}, default='error'
      Whether to raise an error or ignore if an unknown categorical feature
      is present during transform (default is to raise). When this parameter
      is set to 'ignore' and an unknown category is encountered during
      transform, the resulting one-hot encoded columns for this feature
      will be all zeros. In the inverse transform, an unknown category
      will be denoted as None.
  handle : cuml.Handle
      Specifies the cuml.handle that holds internal CUDA state for
      computations in this model. Most importantly, this specifies the CUDA
      stream that will be used for the model's computations, so users can
      run different models concurrently in different streams by creating
      handles in several streams.
      If it is None, a new one is created.
  verbose : int or boolean, default=False
      Sets logging level. It must be one of `cuml.common.logger.level_*`.
      See :ref:`verbosity-levels` for more info.
  output_type : {'input', 'array', 'dataframe', 'series', 'df_obj',         'numba', 'cupy', 'numpy', 'cudf', 'pandas'}, default=None
      Return results and set estimator attributes to the indicated output
      type. If None, the output type set at the module level
      (`cuml.global_settings.output_type`) will be used. See
      :ref:`output-data-type-configuration` for more info.
  
  Attributes
  ----------
  drop_idx_ : array of shape (n_features,)
      ``drop_idx_[i]`` is the index in ``categories_[i]`` of the category to
      be dropped for each feature. None if all the transformed features will
      be retained.
class_docstr_tok: ["Encode","categorical","features","as","a","one-hot","numeric","array",".","The","input","to","this","estimator","should","be","a",":","py",":","class",":","`","cuDF.DataFrame","`","or","a",":","py",":","class",":","`","cupy.ndarray","`",",","denoting","the","unique","values","taken","on","by","categorical","(","discrete",")","features",".","The","features","are","encoded","using","a","one-hot","(","aka","'one-of-K","'","or","'dummy","'",")","encoding","scheme",".","This","creates","a","binary","column","for","each","category","and","returns","a","sparse","matrix","or","dense","array","(","depending","on","the","``","sparse","``","parameter",")",".","By","default",",","the","encoder","derives","the","categories","based","on","the","unique","values","in","each","feature",".","Alternatively",",","you","can","also","specify","the","`","categories","`","manually",".","..","note",":",":","a","one-hot","encoding","of","y","labels","should","use","a","LabelBinarizer","instead",".","Parameters","--","--","--","--","--","categories",":","'auto","'","an","cupy.ndarray","or","a","cudf.DataFrame",",","default='auto'","Categories","(","unique","values",")","per","feature",":","-","'auto","'",":","Determine","categories","automatically","from","the","training","data",".","-","DataFrame\/ndarray",":","``","categories","[","col","]","``","holds","the","categories","expected","in","the","feature","col.","drop",":","'first","'",",","None",",","a","dict","or","a","list",",","default=None","Specifies","a","methodology","to","use","to","drop","one","of","the","categories","per","feature",".","This","is","useful","in","situations","where","perfectly","collinear","features","cause","problems",",","such","as","when","feeding","the","resulting","data","into","a","neural","network","or","an","unregularized","regression",".","-","None",":","retain","all","features","(","the","default",")",".","-","'first","'",":","drop","the","first","category","in","each","feature",".","If","only","one","category","is","present",",","the","feature","will","be","dropped","entirely",".","-","dict\/list",":","``","drop","[","col","]","``","is","the","category","in","feature","col","that","should","be","dropped",".","sparse",":","bool",",","default=True","This","feature","is","not","fully","supported","by","cupy","yet",",","causing","incorrect","values","when","computing","one","hot","encodings",".","See","https",":","\/\/github.com\/cupy\/cupy\/issues\/3223","dtype",":","number","type",",","default=np.float","Desired","datatype","of","transform","'s","output",".","handle_unknown",":","{","'error","'",",","'ignore","'","}",",","default='error'","Whether","to","raise","an","error","or","ignore","if","an","unknown","categorical","feature","is","present","during","transform","(","default","is","to","raise",")",".","When","this","parameter","is","set","to","'ignore","'","and","an","unknown","category","is","encountered","during","transform",",","the","resulting","one-hot","encoded","columns","for","this","feature","will","be","all","zeros",".","In","the","inverse","transform",",","an","unknown","category","will","be","denoted","as","None",".","handle",":","cuml.Handle","Specifies","the","cuml.handle","that","holds","internal","CUDA","state","for","computations","in","this","model",".","Most","importantly",",","this","specifies","the","CUDA","stream","that","will","be","used","for","the","model","'s","computations",",","so","users","can","run","different","models","concurrently","in","different","streams","by","creating","handles","in","several","streams",".","If","it","is","None",",","a","new","one","is","created",".","verbose",":","int","or","boolean",",","default=False","Sets","logging","level",".","It","must","be","one","of","`","cuml.common.logger.level_","*","`",".","See",":","ref",":","`","verbosity-levels","`","for","more","info",".","output_type",":","{","'input","'",",","'array","'",",","'dataframe","'",",","'series","'",",","'df_obj","'",",","'numba","'",",","'cupy","'",",","'numpy","'",",","'cudf","'",",","'pandas","'","}",",","default=None","Return","results","and","set","estimator","attributes","to","the","indicated","output","type",".","If","None",",","the","output","type","set","at","the","module","level","(","`","cuml.global_settings.output_type","`",")","will","be","used",".","See",":","ref",":","`","output-data-type-configuration","`","for","more","info",".","Attributes","--","--","--","--","--","drop_idx_",":","array","of","shape","(","n_features",",",")","``","drop_idx_","[","i","]","``","is","the","index","in","``","categories_","[","i","]","``","of","the","category","to","be","dropped","for","each","feature",".","None","if","all","the","transformed","features","will","be","retained","."]
docstr: Transform X using one-hot encoding.
code: def transform(self, X):
      """Transform X using one-hot encoding."""
      self._check_is_fitted()
      X = self._check_input(X)
  
      cols, rows = list(), list()
      col_idx = None
      j = 0
  
      try:
          for feature in X.columns:
              encoder = self._encoders[feature]
              col_idx = encoder.transform(X[feature])
              idx_to_keep = col_idx.notnull().to_cupy()
              col_idx = col_idx.dropna().to_cupy()
  
              # Simple test to auto upscale col_idx type as needed
              # First, determine the maximum value we will add assuming
              # monotonically increasing up to len(encoder.classes_)
              # Ensure we dont go negative by clamping to 0
              max_value = int(max(len(encoder.classes_) - 1, 0) + j)
  
              # If we exceed the max value, upconvert
              if max_value > np.iinfo(col_idx.dtype).max:
                  col_idx = col_idx.astype(
                      np.min_scalar_type(max_value)
                  )
                  logger.debug(
                      "Upconverting column: '{}', to dtype: '{}', "
                      "to support up to {} classes".format(
                          feature,
                          np.min_scalar_type(max_value),
                          max_value,
                      )
                  )
  
              # increase indices to take previous features into account
              col_idx += j
  
              # Filter out rows with null values
              row_idx = cp.arange(len(X))[idx_to_keep]
  
              if self.drop_idx_ is not None:
                  drop_idx = self.drop_idx_[feature] + j
                  mask = cp.ones(col_idx.shape, dtype=bool)
                  mask[col_idx == drop_idx] = False
                  col_idx = col_idx[mask]
                  row_idx = row_idx[mask]
                  # account for dropped category in indices
                  col_idx[col_idx > drop_idx] -= 1
                  # account for dropped category in current cats number
                  j -= 1
  
              j += len(encoder.classes_)
              cols.append(col_idx)
              rows.append(row_idx)
  
          cols = cp.concatenate(cols)
          rows = cp.concatenate(rows)
          val = cp.ones(rows.shape[0], dtype=self.dtype)
          ohe = cupyx.scipy.sparse.coo_matrix(
              (val, (rows, cols)), shape=(len(X), j), dtype=self.dtype
          )
  
          if not self.sparse:
              ohe = ohe.toarray()
  
          return ohe
  
      except TypeError as e:
          # Append to cols to include the column that threw the error
          cols.append(col_idx)
  
          # Build a string showing what the types are
          input_types_str = ", ".join([str(x.dtype) for x in cols])
  
          raise TypeError(
              "A TypeError occurred while calculating column "
              "category indices, most likely due to integer overflow. This "
              "can occur when columns have a large difference in the number "
              "of categories, resulting in different category code dtypes "
              "for different columns."
              "Calculated column code dtypes: {}.\n"
              "Internal Error: {}".format(input_types_str, repr(e))
          )
  
imports: import warnings
  from typing import List, Optional, TypeVar
  import cuml.internals.logger
  from cudf import DataFrame, Series
  from cuml import Base
  from cuml.common.doc_utils import generate_docstring
  from cuml.common.exceptions import NotFittedError
  from cuml.internals.safe_imports import cpu_only_import, gpu_only_import, gpu_only_import_from
  from cuml.preprocessing import LabelEncoder
label_desc: Use image node_id 9 for calling the OneHotEncoder obj's underlying member method code with example usage: obj.transform(X) and returns: ohe