skopt.space.space
.Categorical¶
-
class
skopt.space.space.
Categorical
(categories, prior=None, transform=None, name=None)[source][source]¶ Search space dimension that can take on categorical values.
- Parameters
- categorieslist, shape=(n_categories,)
Sequence of possible categories.
- priorlist, shape=(categories,), default=None
Prior probabilities for each category. By default all categories are equally likely.
- transform“onehot”, “string”, “identity”, default=”onehot”
“identity”, the transformed space is the same as the original space.
“string”, the transformed space is a string encoded
representation of the original space.
“onehot”, the transformed space is a one-hot encoded representation of the original space.
- namestr or None
Name associated with dimension, e.g., “colors”.
- Attributes
- bounds
- name
- prior
- size
- transformed_bounds
- transformed_size
Methods
distance
(self, a, b)Compute distance between category
a
andb
.inverse_transform
(self, Xt)Inverse transform samples from the warped space back into the original space.
rvs
(self[, n_samples, random_state])Draw random samples.
transform
(self, X)Transform samples form the original space to a warped space.
-
__init__
(self, categories, prior=None, transform=None, name=None)[source][source]¶ Initialize self. See help(type(self)) for accurate signature.
-
distance
(self, a, b)[source][source]¶ Compute distance between category
a
andb
.As categories have no order the distance between two points is one if a != b and zero otherwise.
- Parameters
- acategory
First category.
- bcategory
Second category.
-
inverse_transform
(self, Xt)[source]¶ Inverse transform samples from the warped space back into the original space.