skopt.space.transformers.StringEncoder

class skopt.space.transformers.StringEncoder(dtype=<class 'str'>)[source][source]

StringEncoder transform. The transform will cast everything to a string and the inverse transform will cast to the type defined in dtype.

Methods

fit(X)

Fit a list or array of categories.

inverse_transform(Xt)

Inverse transform string encoded categories back to their original

transform(X)

Transform an array of categories to a string encoded representation.

__init__(dtype=<class 'str'>)[source][source]

Initialize self. See help(type(self)) for accurate signature.

fit(X)[source][source]

Fit a list or array of categories. All elements must be from the same type.

Parameters
Xarray-like, shape=(n_categories,)

List of categories.

inverse_transform(Xt)[source][source]
Inverse transform string encoded categories back to their original

representation.

Parameters
Xtarray-like, shape=(n_samples,)

String encoded categories.

Returns
Xarray-like, shape=(n_samples,)

The original categories.

transform(X)[source][source]

Transform an array of categories to a string encoded representation.

Parameters
Xarray-like, shape=(n_samples,)

List of categories.

Returns
Xtarray-like, shape=(n_samples,)

The string encoded categories.