skopt.space.transformers.CategoricalEncoder#

class skopt.space.transformers.CategoricalEncoder[source][source]#

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__()[source][source]#

Convert labeled categories into one-hot encoded features.

fit(X)[source][source]#

Fit a list or array of categories.

Parameters:
Xarray-like, shape=(n_categories,)

List of categories.

inverse_transform(Xt)[source][source]#

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

Parameters:
Xtarray-like, shape=(n_samples, n_categories)

One-hot encoded categories.

Returns:
Xarray-like, shape=(n_samples,)

The original categories.

transform(X)[source][source]#

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

Parameters:
Xarray-like, shape=(n_samples,)

List of categories.

Returns:
Xtarray-like, shape=(n_samples, n_categories)

The one-hot encoded categories.