Categorical
ConfigSpace.api.types.categorical
#
Categorical
#
Categorical(
name: str,
items: Sequence[T],
*,
default: T | _NotSet = NotSet,
weights: Sequence[float] | None = None,
ordered: bool = False,
meta: dict | None = None
) -> CategoricalHyperparameter | OrdinalHyperparameter
Creates a Categorical Hyperparameter.
CategoricalHyperparameter's can be used to represent a discrete
choice. Optionally, you can specify that these values are also ordered in
some manner, e.g. ["small", "medium", "large"].
# A simple categorical hyperparameter
c = Categorical("animals", ["cat", "dog", "mouse"])
# With a default
c = Categorical("animals", ["cat", "dog", "mouse"], default="mouse")
# Make them weighted
c = Categorical("animals", ["cat", "dog", "mouse"], weights=[0.1, 0.8, 3.14])
# Specify it's an OrdinalHyperparameter (ordered categories)
# ... note that you can't apply weights to an Ordinal
o = Categorical("size", ["small", "medium", "large"], ordered=True)
# Add some meta information for your own tracking
c = Categorical("animals", ["cat", "dog", "mouse"], meta={"use": "Favourite Animal"})
Note
Categorical is actually a function, please use the corresponding return types if
doing an isinstance(param, type) check with either
CategoricalHyperparameter
and/or OrdinalHyperparameter.
| PARAMETER | DESCRIPTION |
|---|---|
name |
The name of the hyperparameter
TYPE:
|
items |
A list of items to put in the category. Warning Can't have duplicate categories, use weights if required.
TYPE:
|
default |
The default value of the categorical hyperparameter.
TYPE:
|
weights |
The weights to apply to each categorical. Each item will be sampled according to these weights. |
ordered |
Whether the categorical is ordered or not. If
TYPE:
|
meta |
Any additional meta information you would like to store along with the hyperparamter.
TYPE:
|