# OneHotEncoder

### *class* cuml.dask.preprocessing.OneHotEncoder(, client=None, verbose=False, \*\*kwargs)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/preprocessing/encoders.py#L33)

Encode categorical features as a one-hot numeric array.

The input to this transformer should be an array-like of integers or
strings, denoting the 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_output`
parameter).

By default, the encoder derives the categories based on the unique values
in each feature. Alternatively, you can also specify the `categories`
manually.

* **Parameters:**
  **categories**
  : Categories (unique values) per feature:
    - ‘auto’ : Determine categories automatically from the training data.
    - list : `categories[i]` holds the categories expected in the ith
      column.

  **drop**
  : 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 an unregularized linear regression model.
    <br/>
    However, dropping one category breaks the symmetry of the original
    representation and can therefore induce a bias in downstream models,
    for instance for penalized linear classification or regression models.
    - 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.
    - array : `drop[i]` is the category in feature `X[:, i]` that
      should be dropped.

  **sparse_output**
  : When `True`, transform returns a sparse matrix/array in CSR format.

  **dtype**
  : Desired dtype of transformed output.

  **handle_unknown**
  : Specifies the way unknown categories are handled during [`transform()`](#cuml.dask.preprocessing.OneHotEncoder.transform).
    - ‘error’ : Raise an error if an unknown category is present during transform.
    - ‘ignore’ : When 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.

### Methods

| [`fit`](#cuml.dask.preprocessing.OneHotEncoder.fit)(X)                          | Fit a multi-node multi-gpu OneHotEncoder to X.        |
|----------------------------------------------------------------------------------|-------------------------------------------------------|
| [`inverse_transform`](#cuml.dask.preprocessing.OneHotEncoder.inverse_transform)(X[, delayed]) | Convert the data back to the original representation. |
| [`transform`](#cuml.dask.preprocessing.OneHotEncoder.transform)(X[, delayed])         | Transform X using one-hot encoding.                   |
<!-- !! processed by numpydoc !! -->

#### fit(X)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/preprocessing/encoders.py#L94)

Fit a multi-node multi-gpu OneHotEncoder to X.

* **Parameters:**
  **X**
  : The data to determine the categories of each feature.
* **Returns:**
  self

<!-- !! processed by numpydoc !! -->

#### fit_transform(X, delayed=True)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/preprocessing/encoders.py#L15)

Fit the encoder to X, then transform X. Equivalent to fit(X).transform(X).

* **Parameters:**
  **X**
  : The data to encode.

  **delayed**
  : Whether to execute as a delayed task or eager.
* **Returns:**
  **out**
  : Distributed object containing the transformed data

<!-- !! processed by numpydoc !! -->

#### get_combined_model()[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/common/base.py#L57)

Return single-GPU model for serialization

* **Returns:**
  **model**
  : yet been trained.

<!-- !! processed by numpydoc !! -->

#### inverse_transform(X, delayed=True)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/preprocessing/encoders.py#L151)

Convert the data back to the original representation.

* **Parameters:**
  **X**
  : The transformed data.

  **delayed**
  : Whether to execute as a delayed task or eager.
* **Returns:**
  **X_tr**
  : Distributed object containing the inverse transformed array.

<!-- !! processed by numpydoc !! -->

#### transform(X, delayed=True)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/preprocessing/encoders.py#L125)

Transform X using one-hot encoding.

* **Parameters:**
  **X**
  : The data to encode.

  **delayed**
  : Whether to execute as a delayed task or eager.
* **Returns:**
  **out**
  : Distributed object containing the transformed input.

<!-- !! processed by numpydoc !! -->
