Skip to main content
`Ctrl`+`K`

# `skopt.space.transformers`.CategoricalEncoder

class skopt.space.transformers.CategoricalEncoder

  OneHotEncoder that can handle categorical variables.

  Methods

  `fit`(X) | Fit a list or array of categories.
  `inverse_transform`(Xt) | Inverse transform one-hot encoded categories back to their original representation.
  `transform`(X) | Transform an array of categories to a one-hot encoded representation.

  __init__()

    Convert labeled categories into one-hot encoded features.

  fit(X)

    Fit a list or array of categories.

    Parameters:
      X array-like, shape=(n_categories,)

        List of categories.

  inverse_transform(Xt)

    Inverse transform one-hot encoded categories back to their original representation.

    Parameters:
      Xt array-like, shape=(n_samples, n_categories)

        One-hot encoded categories.

    Returns:
      X array-like, shape=(n_samples,)

        The original categories.

  transform(X)

    Transform an array of categories to a one-hot encoded representation.

    Parameters:
      X array-like, shape=(n_samples,)

        List of categories.

    Returns:
      Xt array-like, shape=(n_samples, n_categories)

        The one-hot encoded categories.