# Creating Continuous Search Spaces This example illustrates several ways to create continuous spaces space. ## Imports ```python import numpy as np ``` ```python from baybe.parameters import NumericalContinuousParameter from baybe.searchspace import SearchSpace, SubspaceContinuous ``` ## Settings We begin by defining the continuous parameters that span our space: ```python DIMENSION = 4 BOUNDS = (-1, 1) ``` ```python parameters = [ NumericalContinuousParameter(name=f"x_{k + 1}", bounds=BOUNDS) for k in range(DIMENSION) ] ``` From these parameter objects, we can now construct a continuous subspace. Let us draw some samples from it and verify that they are within the bounds: ```python subspace = SubspaceContinuous(parameters) samples = subspace.sample_uniform(10) print(samples) assert np.all(samples >= BOUNDS[0]) and np.all(samples <= BOUNDS[1]) ``` x_1 x_2 x_3 x_4 0 0.685489 0.248342 -0.796223 -0.466407 1 0.456789 -0.555102 -0.015712 -0.599814 2 0.787084 -0.982555 0.443189 -0.633126 3 -0.482222 0.957662 0.076014 -0.816454 4 0.540017 0.770043 -0.981446 0.485151 5 -0.803854 -0.283810 0.424097 0.698361 6 -0.932789 -0.047176 -0.293533 0.463930 7 0.978280 -0.655145 0.287556 0.282823 8 -0.064457 -0.960140 -0.376689 -0.234328 9 0.845942 0.643969 -0.083186 0.866484 There are several ways we can turn the above objects into a search space. This provides a lot of flexibility depending on the context: ```python # Using conversion: searchspace1 = SubspaceContinuous(parameters).to_searchspace() ``` ```python # Explicit attribute assignment via the regular search space constructor: searchspace2 = SearchSpace(continuous=SubspaceContinuous(parameters)) ``` ```python # Using an alternative search space constructor: searchspace3 = SearchSpace.from_product(parameters=parameters) ``` No matter which version we choose, we can be sure that the resulting search space objects are equivalent: ```python assert searchspace1 == searchspace2 == searchspace3 ```