optuna.distributions.CategoricalDistribution

class optuna.distributions.CategoricalDistribution(choices)[源代码]

A categorical distribution.

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

参数

choices (Sequence[Union[None, bool, int, float, str]]) – Parameter value candidates.

返回类型

None

备注

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.

引发

ValueError – If choices do not contain any elements.

参数

choices (Sequence[Union[None, bool, int, float, str]]) –

返回类型

None

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()[源代码]

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

返回

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

返回类型

bool

to_external_repr(param_value_in_internal_repr)[源代码]

Convert internal representation of a parameter value into external representation.

参数

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

返回

Optuna’s external representation of a parameter value.

返回类型

Union[None, bool, int, float, str]

to_internal_repr(param_value_in_external_repr)[源代码]

Convert external representation of a parameter value into internal representation.

参数

param_value_in_external_repr (Union[None, bool, int, float, str]) – Optuna’s external representation of a parameter value.

返回

Optuna’s internal representation of a parameter value.

返回类型

float