# 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.143819 0.260934 0.843463 0.871500 1 -0.735991 0.615088 0.524823 0.872683 2 -0.566570 -0.843687 0.582577 0.013269 3 -0.544481 0.553666 -0.495131 -0.552246 4 0.213853 0.580507 0.956558 0.048166 5 0.960008 0.345645 0.343701 0.250070 6 -0.379563 -0.922029 -0.569487 0.690354 7 -0.404176 0.459581 0.816093 -0.860763 8 -0.742969 0.301109 0.755132 0.656473 9 0.523162 0.044365 -0.902320 0.286269 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 ```