Skip to content

parameterspace.base

SearchSpace

Abstract base class for different search space implementations.

copy(self)

Get a copy that behaves exactly like the original SearchSpace. Call seed() on the copy to get independent samples.

Source code in parameterspace/base.py
@abc.abstractmethod
def copy(self):
    """Get a copy that behaves exactly like the original `SearchSpace`.
    Call `seed()` on the copy to get independent samples.
    """

from_numerical(self, vector)

Convert a np.float64 type vector numerical representation of a configuration from this space to a dictionary representation.

Source code in parameterspace/base.py
@abc.abstractmethod
def from_numerical(self, vector: np.ndarray) -> dict:
    """Convert a np.float64 type vector numerical representation of a configuration
    from this space to a dictionary representation."""

sample(self)

Provide a dictionary with one key corresponding to each parameter name and its value representing a sample for that parameter.

Source code in parameterspace/base.py
@abc.abstractmethod
def sample(self) -> dict:
    """Provide a dictionary with one key corresponding to each parameter name and
    its value representing a sample for that parameter.
    """

seed(self, seed)

Reinitialize the random number generator with a new seed.

Source code in parameterspace/base.py
@abc.abstractmethod
def seed(self, seed: int) -> None:
    """Reinitialize the random number generator with a new seed."""

to_numerical(self, configuration)

Given a configuration from this space, create a numerical vector representation. The transformed representation needs to be between 0 and 1 (uniform), including integers, ordinal and categoricals. Inactive parameters have to be represented with np.nan

Source code in parameterspace/base.py
@abc.abstractmethod
def to_numerical(self, configuration: dict) -> np.ndarray:
    """Given a configuration from this space, create a numerical vector
    representation.
    The transformed representation needs to be between 0 and 1 (uniform), including
    integers, ordinal and categoricals.
    Inactive parameters have to be represented with `np.nan`
    """