Skip to content

Commit

Permalink
Revise outdated search space user guide section
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSosic committed Nov 9, 2024
1 parent 9e3acc1 commit 94c018c
Showing 1 changed file with 5 additions and 67 deletions.
72 changes: 5 additions & 67 deletions docs/userguide/searchspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,79 +222,17 @@ The function [`SearchSpace.from_product`](baybe.searchspace.core.SearchSpace.fro
### Constructing from a Dataframe

[`SearchSpace.from_dataframe`](baybe.searchspace.core.SearchSpace.from_dataframe) constructs a search space from a given dataframe.
Due to the ambiguity between discrete and numerical parameter choices, this function requires a parameters list with pre-defined parameter objects, unlike its subspace counterparts, where this list is optional.
Due to the ambiguity between discrete and continuous parameter representations when identifying parameter ranges based only on data, this function requires that the appropriate parameter definitions be explicitly provided. This is different for its subspace counterparts [`SubspaceDiscrete.from_dataframe`](baybe.searchspace.discrete.SubspaceDiscrete.from_dataframe) and [`SubspaceContinuous.from_dataframe`](baybe.searchspace.continuous.SubspaceContinuous.from_dataframe), where a fallback mechanism can automatically infer minimal parameter specifications if omitted.

```python
from baybe.searchspace import SearchSpace

params = [
NumericalDiscreteParameter(name="x0", values=[1, 2, 3]),
NumericalDiscreteParameter(name="x1", values=[4, 5, 6]),
NumericalContinuousParameter(name="x2", bounds=(6, 9)),
]

df = pd.DataFrame(
{
"x0": [2, 3],
"x1": [5, 4],
"x2": [9, 7],
}
)
searchspace = SearchSpace.from_dataframe(df=df, parameters=params)
p_cont = NumericalContinuousParameter(name="c", bounds=[0, 1])
p_disc = NumericalDiscreteParameter(name="d", values=[1, 2, 3])
df = pd.DataFrame({"c": [0.3, 0.7], "d": [2, 3]})
searchspace = SearchSpace.from_dataframe(df=df, parameters=[p_cont, p_disc])
```

Since one of the provided parameters is continuous, this creates a hybrid space.
The following shows *all* information that are available to the user for this space:

~~~
Search Space
Search Space Type: HYBRID
Discrete Search Space
Discrete Parameters
Name Type Num_Values Encoding
0 x0 NumericalDiscreteParameter 3 None
1 x1 NumericalDiscreteParameter 3 None
Experimental Representation
x0 x1
0 2 5
1 3 4
Metadata:
was_recommended: 0/2
was_measured: 0/2
dont_recommend: 0/2
Constraints
Empty DataFrame
Columns: []
Index: []
Computational Representation
x0 x1
0 2 5
1 3 4
Continuous Search Space
Continuous Parameters
Name Type Lower_Bound Upper_Bound
0 x2 NumericalContinuousParameter 6.0 9.0
List of Linear Equality Constraints
Empty DataFrame
Columns: []
Index: []
List of Linear Inequality Constraints
Empty DataFrame
Columns: []
Index: []
~~~

## Restricting Search Spaces Using Constraints

Most constructors for both subspaces and search spaces support the optional keyword argument `constraints` to provide a list of [`Constraint`](baybe.constraints.base.Constraint) objects.
Expand Down

0 comments on commit 94c018c

Please sign in to comment.