Skip to main content

Experimental design and Bayesian optimization with Gaussian Processes and QMC sampling

Project description

ChemBayes

ChemBayes is a Python library designed to streamline experimental design (DoE) and Bayesian optimization for scientific and chemical research. It leverages Gaussian Processes to model complex response surfaces and efficiently identify optimal conditions.

🚀 Key Features

  • Intelligent Sampling (QMC): Generate initial experimental designs using Halton sequences (Quasi-Monte Carlo) for optimal space-filling coverage.
  • Automatic Preprocessing: Integrated handling of numeric variables (scaling) and categorical variables (one-hot encoding).
  • Hyperparameter Tuning: Automated Gaussian Process parameter adjustment (Matern + WhiteKernel) using Leave-One-Out (LOO) cross-validation and NLPD loss.
  • Bayesian Optimization: Global maximum search using the Expected Improvement (EI) acquisition function.
  • Visual Diagnostics: Automated generation of feature importance, partial dependence plots (1D and 2D), and model validation charts.

📦 Installation

From the project root (where pyproject.toml is located):

pip install .

Or for development mode:

pip install -e .

🛠️ Quick Start

1. Generating an Experimental Design (Sampling)

Define your search space with numeric and categorical parameters:

import chembayes as cb

parameters = {
    'temperature': {'type': 'float', 'l_bound': 20.0, 'u_bound': 100.0},
    'time': {'type': 'int', 'l_bound': 5, 'u_bound': 60},
    'catalyst': {'type': 'categoric', 'categories': ['Pd', 'Ni', 'Cu']}
}

# Generate 20 optimal experimental points
df_experiments = cb.qmc_sampling(parameters, n_points=20)

# Visualize the distribution
cb.plot_qmc_sampling(df_experiments)

2. Bayesian Optimization

Once you have experimental data, find the optimal conditions:

# Define input features and the target column
inputs = ['temperature', 'time', 'catalyst']
output = 'yield'

# Run the complete optimization pipeline
results = cb.optimize_experiment(
    df=df_data, 
    inputs=inputs, 
    output=output,
    n_tuning_trials=50,
    n_opt_trials=100
)

# Access the best found parameters
print(f"Best configuration: {results['best_params']}")

📂 Project Structure

  • src/chembayes/sampler.py: Tools for QMC sample generation.
  • src/chembayes/optimizer.py: Bayesian optimization engine and Gaussian Processes.
  • src/chembayes/__init__.py: Public API exposure.
  • pyproject.toml: Modern package configuration and dependencies.

✉️ Contact & Contribution

Author: Jesus Alberto Martin del Campo
Email: j.a.martin-campo@hotmail.com
GitHub: jesusalmartin/chembayes

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

chembayes-0.1.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

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

chembayes-0.1.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file chembayes-0.1.0.tar.gz.

File metadata

  • Download URL: chembayes-0.1.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for chembayes-0.1.0.tar.gz
Algorithm Hash digest
SHA256 73e61663d60ed4b9eb0d73139d19ad652b455e72bfbeb2550d00b7105387448c
MD5 066bff7e14731c6be2e2d0f877f279c6
BLAKE2b-256 a51b254c99ddde657032bf7ae76faab1e897f959463c0853ae1d8f4a0bf8adf9

See more details on using hashes here.

File details

Details for the file chembayes-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: chembayes-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for chembayes-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 417c6afbcfdd8a5a66bac8798651586ff52d5938384092fb08e5a3a7630a2894
MD5 07d411dc14e88b35a90578d4f346ce72
BLAKE2b-256 6521a338a8a6d3759e9e80dc87a58a6ffcf4e888ef0d98bc27641fb9f49ac772

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