btb.tuning.hyperparams.boolean module

Package where the BooleanHyperParam class is defined.

class btb.tuning.hyperparams.boolean.BooleanHyperParam(default=False)[source]

Bases: btb.tuning.hyperparams.base.BaseHyperParam

BooleanHyperParam class.

The BooleanHyperParam class is responsible for the transformation of boolean values in to normalized search space of \([0, 1]\), providing the ability to sample values of those and to inverse transform from the search space into the hyperparameter space.

Hyperparameter space:

{True, False}

Parameters

default (bool) – Default boolean value for the hyperparameter. Defaults to False.

cardinality = 2
dimensions = 1
sample(n_samples)[source]

Generate sample values in the hyperparameter search space \({0, 1}\).

Parameters

n_samples (int) – Number of values to sample.

Returns

2D array with shape of (n_samples, 1) with normalized values inside the search space \({0, 1}\).

Return type

numpy.ndarray

Example

The example below shows simple usage case where a BooleanHyperParam is being created and it’s sample method is being called with a number of samples to be obtained.

>>> instance = BooleanHyperParam()
>>> instance.sample(2)
array([[1],
       [1]])