EmptySpaceSampler
An advanced Optuna sampler that uses the ess (EmptySpaceSearch) library to iteratively find and sample the largest unexplored "gaps" in the search space.
The problem
Standard samplers can struggle with coverage:
RandomSamplercan create "clumps," leaving large areas unexplored by pure chance.TPESampler(and other Bayesian methods) quickly focus on "promising" areas. This is good for exploitation but bad for exploration. If the initial samples are poor, the sampler may never find better regions.
The Solution: EmptySpaceSampler
ESSampler is designed to provide maximum coverage by iteratively filling in the largest empty regions of the search space.
How It Works
- Trial 1 (Random): The sampler lets RandomSampler (via sample_independent) handle the very first trial. This trial's parameters are used to define the boundaries of the full search space.
- Sampler Initialization (Trial 2):
ESSamplerdetects the now-defined search space.- It generates an initial batch of n (default 10) random "anchor points" in a normalized [0, 1] unit cube.
- It calls the ess.esa() function, feeding it these anchors. ess.esa() returns n new points that are located in the largest "empty" spaces between the anchors.
- The sampler creates an internal queue of 2*n points (the anchors + the new points).
- Iterative Sampling (Trials 2+):
- For the next 2*n trials,
ESSamplersimply serves one point from its internal queue. - Each [0, 1] point is intelligently mapped to the actual parameter values, correctly handling log, step, int, and categorical distributions.
- For the next 2*n trials,
- Refilling the Queue:
- Once the queue is empty, the entire set of 2*n points that were just sampled become the new anchors.
- ess.esa() is called again with these new, denser anchors to find the next n points in the now-smaller gaps.
- This process repeats, progressively filling the search space with more and more detail.
Features
- Iterative Gap-Filling: Uses ess.esa to progressively sample the largest unexplored regions.
- Automatic Space Detection: No setup needed. The sampler discovers the search space from the first trial.
- Full Distribution Support: A robust mapping function correctly converts [0, 1] unit values to Float, Int, and Categorical types, including log and step modifiers.
- Configurable Intensity: You can control how many points are generated in each batch with the samples parameter.
Authors
License
This project is licensed under the MIT License. MIT License
Copyright (c) 2025 Mário Antunes
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Metadata
Release files for emptyspacesampler 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| emptyspacesampler-0.1.tar.gz | 6.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| emptyspacesampler-0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.4 kB
Release files / emptyspacesampler-0.1.tar.gz
| Download URL | emptyspacesampler-0.1.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67b636f8da4ac90e3b6219e8fc523b9d460bf99197290da9c772f2a9b52206be
|
|
BLAKE2b-256 checksum How to use checksums |
199fff41b777d1a2c0a6bcb95499ddf3917fbc782e608b4d285aac6305877609
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / emptyspacesampler-0.1-py3-none-any.whl
| Download URL | emptyspacesampler-0.1-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c32b3adab3e6277e60e13d8ce80103047d671702b395016549bcfe0f8cc96eaa
|
|
BLAKE2b-256 checksum How to use checksums |
f6c2a024874dd325b149c1881323198a6a5a1534790301f43cfd885e31fe9d1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for emptyspacesampler 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.