Distributions¶

class
optuna.distributions.
UniformDistribution
(low, high)[source]¶ A uniform distribution in the linear domain.
This object is instantiated by
suggest_uniform()
, and passed tosamplers
in general.
low
¶ Lower endpoint of the range of the distribution.
low
is included in the range.

high
¶ Upper endpoint of the range of the distribution.
high
is excluded from the range.


class
optuna.distributions.
LogUniformDistribution
(low, high)[source]¶ A uniform distribution in the log domain.
This object is instantiated by
suggest_loguniform()
, and passed tosamplers
in general.
low
¶ Lower endpoint of the range of the distribution.
low
is included in the range.

high
¶ Upper endpoint of the range of the distribution.
high
is excluded from the range.


class
optuna.distributions.
DiscreteUniformDistribution
(low: float, high: float, q: float)[source]¶ A discretized uniform distribution in the linear domain.
This object is instantiated by
suggest_discrete_uniform()
, and passed tosamplers
in general.Note
If the range \([\mathsf{low}, \mathsf{high}]\) is not divisible by \(q\), \(\mathsf{high}\) will be replaced with the maximum of \(k q + \mathsf{low} \lt \mathsf{high}\), where \(k\) is an integer.

low
¶ Lower endpoint of the range of the distribution.
low
is included in the range.

high
¶ Upper endpoint of the range of the distribution.
high
is included in the range.

q
¶ A discretization step.


class
optuna.distributions.
IntUniformDistribution
(low: int, high: int, step: int = 1)[source]¶ A uniform distribution on integers.
This object is instantiated by
suggest_int()
, and passed tosamplers
in general.Note
If the range \([\mathsf{low}, \mathsf{high}]\) is not divisible by \(\mathsf{step}\), \(\mathsf{high}\) will be replaced with the maximum of \(k \times \mathsf{step} + \mathsf{low} \lt \mathsf{high}\), where \(k\) is an integer.

low
¶ Lower endpoint of the range of the distribution.
low
is included in the range.

high
¶ Upper endpoint of the range of the distribution.
high
is included in the range.

step
¶ A step for spacing between values.


class
optuna.distributions.
IntLogUniformDistribution
(low: int, high: int, step: int = 1)[source]¶ A uniform distribution on integers in the log domain.
This object is instantiated by
suggest_int()
, and passed tosamplers
in general.Note
If the range \([\mathsf{low}, \mathsf{high}]\) is not divisible by \(\mathsf{step}\), \(\mathsf{high}\) will be replaced with the maximum of \(k \times \mathsf{step} + \mathsf{low} \lt \mathsf{high}\), where \(k\) is an integer.

low
¶ Lower endpoint of the range of the distribution.
low
is included in the range.

high
¶ Upper endpoint of the range of the distribution.
high
is included in the range.

step
¶ A step for spacing between values.


class
optuna.distributions.
CategoricalDistribution
(choices)[source]¶ A categorical distribution.
This object is instantiated by
suggest_categorical()
, and passed tosamplers
in 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
,float
andstr
.
choices
¶ Parameter value candidates.

optuna.distributions.
distribution_to_json
(dist)[source]¶ Serialize a distribution to JSON format.
 Parameters
dist – A distribution to be serialized.
 Returns
A JSON string of a given distribution.

optuna.distributions.
json_to_distribution
(json_str)[source]¶ Deserialize a distribution in JSON format.
 Parameters
json_str – A JSONserialized distribution.
 Returns
A deserialized distribution.

optuna.distributions.
check_distribution_compatibility
(dist_old, dist_new)[source]¶ A function to check compatibility of two distributions.
Note that this method is not supposed to be called by library users.
 Parameters
dist_old – A distribution previously recorded in storage.
dist_new – A distribution newly added to storage.
 Returns
True denotes given distributions are compatible. Otherwise, they are not.