Skip to main content

Global-Local-Unexplored Sampling Strategy for Bayesian Optimization

Project description

aichem-gloss

PyPI version Documentation Status License: MIT Python Version

Global-Local-Unexplored Sampling Strategy (GLOSS)

Overview

aichem-gloss is a Python package that implements the GLOSS algorithm, a optimization recommender that combines three complementary search strategies:

  • Global Search: Explores the parameter space using acquisition functions with uncertainty quantification (UCB/LCB)
  • Local Search: Exploits promising regions around the best known points for refinement
  • Unexplored Search: Discovers underexplored regions of the parameter space with distance-based filtering

This package is particularly useful for:

  • 🧪 Chemical space exploration and molecular design
  • 🔬 Materials discovery and optimization
  • ⚙️ Hyperparameter optimization for machine learning
  • 🎯 Any expensive black-box optimization problem
  • 🤖 Robotic chemistry and automated experimentation

Features

  • Three-strategy approach: Balanced exploration and exploitation with unexplored region discovery
  • 🔄 Strict deduplication: Ensures diverse and non-redundant recommendations
  • 🎯 Model-agnostic: Works with any scikit-learn compatible model (GP, RF, etc.)
  • 🚀 Easy to use: Simple API with sensible defaults
  • 📊 Well-documented: Comprehensive documentation and examples
  • 🔧 Flexible: Customizable strategy distribution and acquisition parameters

Installation

From PyPI

pip install aichem-gloss

From Conda

conda install -c conda-forge aichem-gloss

From Source

git clone https://github.com/pic-ai-robotic-chemistry/aichem-gloss.git
cd aichem-gloss
pip install -e .

Quick Start

import numpy as np
from sklearn.gaussian_process import GaussianProcessRegressor
from aichem_gloss import GLOSSRecommender

# Define parameter bounds
bounds = [[-5, 5], [-5, 5]]

# Create and train a surrogate model
model = GaussianProcessRegressor()
X_train = np.random.uniform(-5, 5, (20, 2))
y_train = np.sum(X_train**2, axis=1)  # Example objective
model.fit(X_train, y_train)

# Create GLOSS recommender
recommender = GLOSSRecommender(
    model=model,
    bounds=bounds,
    y_better_is_smaller=True,  # Minimization problem
    kappa=1.96,  # Exploration parameter
    exploration_fraction=0.5
)

# Fit with historical data
recommender.fit(X_train, y_train)

# Get recommendations
suggestions = recommender.suggest(n_recommend=8)
print("Recommended points:", suggestions['mixed'])

Documentation

Full documentation is available at aichem-gloss.readthedocs.io

Examples

Check out the examples directory for more detailed usage examples:

  • basic_usage.py: Basic optimization with Gaussian Process
  • Using with Random Forest models
  • Custom acquisition functions
  • Multi-objective optimization scenarios

Algorithm Details

The GLOSS algorithm distributes recommendations across three strategies:

Strategy Distribution

  • For n_recommend > 3:
    • Global: 50% of recommendations (exploration with UCB/LCB)
    • Local: 25% of recommendations (exploitation around best points)
    • Unexplored: 25% of recommendations (distance-based unexplored search)
  • For n_recommend ≤ 3: All recommendations use global search

Key Features

  1. Strict Sequential Deduplication: Each new candidate is checked against all previously generated points to ensure diversity
  2. Dynamic History Injection: The unexplored search dynamically updates its reference points to avoid recently generated candidates
  3. Adaptive Repulsion Radius: Automatically calculated based on the density of historical points
  4. Fallback Mechanisms: Multiple fallback strategies ensure robust recommendation generation

API Overview

GLOSSRecommender

GLOSSRecommender(
    model=None,                    # Surrogate model (scikit-learn compatible)
    bounds=None,                   # Parameter bounds [[min, max], ...]
    y_better_is_smaller=False,     # True for minimization, False for maximization
    kappa=1.96,                    # Exploration-exploitation trade-off
    exploration_fraction=0.5       # Unexploredd region threshold (0.0-0.99)
)

Main Methods

  • fit(X, y): Fit the recommender with historical data
  • suggest(n_recommend): Generate new candidate points
  • get_num_recommends(n_recommend): Calculate strategy distribution

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Citation

If you use this package in your research, please cite:

@software{aichem_gloss,
  title = {aichem-gloss: Global-Local-Unexplored Sampling Strategy for Bayesian Optimization},
  author = {Zhang, B.},
  year = {2025},
  url = {https://github.com/pic-ai-robotic-chemistry/aichem-gloss}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Developed by the PIC AI Robotic Chemistry team
  • Inspired by Bayesian optimization and active learning research
  • Built with NumPy and SciPy

Contact

Related Projects

  • scikit-optimize: Bayesian optimization library
  • GPyOpt: Gaussian Process optimization
  • Ax: Adaptive experimentation platform

Project details


Download files

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

Source Distribution

aichem_gloss-1.0.0.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

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

aichem_gloss-1.0.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file aichem_gloss-1.0.0.tar.gz.

File metadata

  • Download URL: aichem_gloss-1.0.0.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for aichem_gloss-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e75f3ee37d6ed7352f8968cb9b267cfefa16a82b04177d009342913fe501aa1e
MD5 311a0e8a2bac42576b5f9deb6fba43b1
BLAKE2b-256 fbd03f60f67d47ba21a35692d24380357bf7f481248a886565b4a6dc1f2b0f9b

See more details on using hashes here.

File details

Details for the file aichem_gloss-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: aichem_gloss-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for aichem_gloss-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dce8105bcb84d0402b0222d7abb0f993af6acd8d53e1d41428170f2acd78559b
MD5 6054c5882ed51f481e1cae6f9b8536bc
BLAKE2b-256 ddbaac417d6931273abe1a2b9e153bc924598183075c21020895f80ab8dc299f

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