deephyper.skopt.optimizer.optimizer.Categorical#

class deephyper.skopt.optimizer.optimizer.Categorical(categories, prior=None, transform=None, name=None)[source]#

Bases: Dimension

Search space dimension that can take on categorical values.

Parameters:
  • categories (list, shape=(n_categories,)) – Sequence of possible categories.

  • prior (list, shape=(categories,), default=None) – Prior probabilities for each category. By default all categories are equally likely.

  • transform (str, Optional) –

    • "identity", the transformed space is the same as the original

    space. - "string", the transformed space is a string encoded representation of the original space. - "label", the transformed space is a label encoded representation (integer) of the original space. - "onehot", the transformed space is a one-hot encoded representation of the original space.

  • name (str, Optional) – Name associated with dimension, e.g., "colors".

Methods

distance

Compute distance between category a and b.

inverse_transform

Inverse transform samples from the warped space back into the original space.

rvs

Sample elements from the dimension.

set_transformer

Define _rvs and transformer spaces.

transform

Transform samples form the original space to a warped space.

Attributes

bounds

Bounds of before applying transform/preprocessing.

is_constant

Test if the current dimension is a constant (with only 1 element it its support).

name

Name of the dimension.

prior

size

Dimensionality of sampel from the dimension before the transform/preprocessing.

transformed_bounds

Bounds after applying transform/preprocessing.

transformed_size

Cardinality of the dimension after applying transform/preprocessing.

property bounds#

Bounds of before applying transform/preprocessing.

distance(a, b)[source]#

Compute distance between category a and b.

As categories have no order the distance between two points is one if a != b and zero otherwise.

Args: a : category

First category.

bcategory

Second category.

inverse_transform(Xt)[source]#

Inverse transform samples from the warped space back into the original space.

property is_constant#

Test if the current dimension is a constant (with only 1 element it its support).

property name#

Name of the dimension.

rvs(n_samples=None, random_state=None)[source]#

Sample elements from the dimension.

set_transformer(transform='onehot')[source]#

Define _rvs and transformer spaces.

Parameters:

transform (str) – Can be a value in ['normalize', 'onehot', 'string', 'label', 'identity'].

property size#

Dimensionality of sampel from the dimension before the transform/preprocessing.

transform(X)#

Transform samples form the original space to a warped space.

property transformed_bounds#

Bounds after applying transform/preprocessing.

property transformed_size#

Cardinality of the dimension after applying transform/preprocessing.