optuna.distributions.CategoricalDistribution

class optuna.distributions.CategoricalDistribution(choices)[source]

A categorical distribution.

This object is instantiated by suggest_categorical(), and passed to samplers in general.

Parameters:

choices (Sequence[None | bool | int | float | str]) – Parameter value candidates. choices must have one element at least.

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, float and str.

choices

Parameter value candidates.

Methods

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()[source]

Test whether the range of this distribution contains just a single value.

Returns:

True if the range of this distribution contains just a single value, otherwise False.

Return type:

bool

to_external_repr(param_value_in_internal_repr)[source]

Convert internal representation of a parameter value into external representation.

Parameters:

param_value_in_internal_repr (float) – Optuna’s internal representation of a parameter value.

Returns:

Optuna’s external representation of a parameter value.

Return type:

None | bool | int | float | str

to_internal_repr(param_value_in_external_repr)[source]

Convert external representation of a parameter value into internal representation.

Parameters:

param_value_in_external_repr (None | bool | int | float | str) – Optuna’s external representation of a parameter value.

Returns:

Optuna’s internal representation of a parameter value.

Return type:

float