optuna.distributions.CategoricalDistribution¶
-
class
optuna.distributions.CategoricalDistribution(choices: Sequence[CategoricalChoiceType])[source]¶ A categorical distribution.
This object is instantiated by
suggest_categorical(), and passed tosamplersin general.- Parameters
choices – Parameter value candidates.
Note
Not all types are guaranteed to be compatible with all storages. It is recommended to restrict the types of the choices to
None,bool,int,floatandstr.-
choices¶ Parameter value candidates.
-
__init__(choices: Sequence[CategoricalChoiceType]) → None[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__(choices)Initialize self.
single()Test whether the range of this distribution contains just a single value.
to_external_repr(param_value_in_internal_repr)Convert internal representation of a parameter value into external representation.
to_internal_repr(param_value_in_external_repr)Convert external representation of a parameter value into internal representation.
-
single() → bool[source]¶ Test whether the range of this distribution contains just a single value.
When this method returns
True,samplersalways sample the same value from the distribution.
-
to_external_repr(param_value_in_internal_repr: float) → CategoricalChoiceType[source]¶ Convert internal representation of a parameter value into external representation.
- Parameters
param_value_in_internal_repr – Optuna’s internal representation of a parameter value.
- Returns
Optuna’s external representation of a parameter value.
-
to_internal_repr(param_value_in_external_repr: CategoricalChoiceType) → float[source]¶ Convert external representation of a parameter value into internal representation.
- Parameters
param_value_in_external_repr – Optuna’s external representation of a parameter value.
- Returns
Optuna’s internal representation of a parameter value.