Skip to main content

Empty Space Sampler: An advanced Optuna sampler that uses the EmptySpaceSearch library to iteratively find and sample the largest unexplored "gaps" in the search space.

Project description

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:

  • RandomSampler can 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

  1. 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.
  2. Sampler Initialization (Trial 2):
    • ESSampler detects 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).
  3. Iterative Sampling (Trials 2+):
    • For the next 2*n trials, ESSampler simply 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.
  4. 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.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

emptyspacesampler-0.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

emptyspacesampler-0.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file emptyspacesampler-0.1.tar.gz.

File metadata

  • Download URL: emptyspacesampler-0.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for emptyspacesampler-0.1.tar.gz
Algorithm Hash digest
SHA256 67b636f8da4ac90e3b6219e8fc523b9d460bf99197290da9c772f2a9b52206be
MD5 311409325e4ece2bb4d19a1ffe251778
BLAKE2b-256 199fff41b777d1a2c0a6bcb95499ddf3917fbc782e608b4d285aac6305877609

See more details on using hashes here.

File details

Details for the file emptyspacesampler-0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for emptyspacesampler-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c32b3adab3e6277e60e13d8ce80103047d671702b395016549bcfe0f8cc96eaa
MD5 147f5065e5b071fd81abe230bd7085f1
BLAKE2b-256 f6c2a024874dd325b149c1881323198a6a5a1534790301f43cfd885e31fe9d1a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page