This release is a pre-release and may not be stable for production use.
grAdapt: Gradient-Adaptation for Black-Box Optimization
grAdapt is a Python package for black-box optimization with fixed budget. It is running on top of scikit-learn, scipy and numpy.
It adapts first-order optimization methods to black-box functions by estimating the gradient with different approaches without the need of additional function evaluations. Further, it samples new starting points from multivariate probability distributions to escape local optima. It is a stochastic and sequential model-based optimization method (SMBO). Most SMBO techniques suffer from quadratic, cubic or even worse time complexities. This is caused by refitting the surrogate model without prior information. grAdapt establishes incremental learning and a sliding window technique to improve the complexity significantly. In stock settings, the runtime of grAdapt scales linearly with the number of function evaluations.
Instead of establishing one optimization method, grAdapt is a modular package where the sampling method, surrogate, optimizer, escape function, and the domain constraint can be changed. This makes grAdapt very adaptable to many optimization problems and not only specifically to black-box optimization.
Due to the fixed budget, it suits optimization problems with costly objectives. The most common application of grAdapt is hyperparameter optimization.
It was started in 2019 by Manh Khoi Duong as a project and was since then continually developed, maintained by the author himself under the supervision of Martha Tatusch.
Installation
Dependencies
grAdapt requires:
- numpy ~= 1.18
- scipy ~= 1.4
- scikit-learn ~= 0.22
- tqdm ~= 4.44
- deprecated ~= 1.2.7
How-to install
The current stable release can be installed from the pip distribution by:
$ pip install grAdapt
The nightly release can be installed by pulling this repository, navigating to the source directory and then simply installing the setup.py file:
$ python setup.py install
or alternatively (with VCS Support):
$ pip install git+https://github.com/mkduong-ai/grAdapt.git
Testing
To verify that the installation went well without any complications, go to the source directory, then navigate to tests
$ cd tests
and run:
$ python run_all.py
All tests should end with an OK.
First start: Optimizing the sphere function
import numpy as np
import grAdapt
from grAdapt.models import Sequential
from grAdapt.space.datatype import Integer, Float, Categorical
# Black-Box Function
def sphereMin(x):
return np.sum(x**2)
# create model to optimize
model = Sequential()
# defining search space
var1 = Float(low=-10, high=10)
var2 = Float(low=-10, high=10)
var3 = Float(low=-10, high=10)
bounds = [var1, var2, var3]
# minimize
n_evals = 100 # budget/number of function evaluations
res = model.minimize(sphereMin, bounds, n_evals)
# getting the history
x = res['x']
y = res['y']
# best solutions
x_sol = res['x_sol']
y_sol = res['y_sol']
Citation
When using grAdapt in your publication, we would appreciate if you cite us.
BibTeX entry:
@misc{grAdapt,
title={grAdapt: Gradient-Adaptation for Black-Box Optimization},
author={Manh Khoi Duong and Martha Tatusch and Stefan Conrad and Gunnar W. Klau}
howpublished={The Python Package Index: PyPi}
}
License
This project is distributed under the Apache License 2.0.
Metadata
Release files for grAdapt 0.1.1b8
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 | Actions |
|---|---|---|---|---|
| grAdapt-0.1.1b8.tar.gz | 4.6 MB | Without provenance | Details for grAdapt-0.1.1b8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| grAdapt-0.1.1b8-py3-none-any.whl | Python 3 | none | any | Details for grAdapt-0.1.1b8-py3-none-any.whl |
Total release size: 4.6 MB
Release files / grAdapt-0.1.1b8.tar.gz
| Download URL | grAdapt-0.1.1b8.tar.gz |
|---|---|
| Size | 4.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2f92fbad18b917ffb77567548b962ec76492edd9c633a8d1fa0b39e25b4be8aa
|
|
BLAKE2b-256 checksum How to use checksums |
9636d9c92795b02cf8bf0a36873d96d884305631d8230623298d19ce60cf8516
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/0.0.0 pkginfo/1.6.0 requests/2.24.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.2
|
Release files / grAdapt-0.1.1b8-py3-none-any.whl
| Download URL | grAdapt-0.1.1b8-py3-none-any.whl |
|---|---|
| Size | 66.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ff8300eeae6b4ea6a6a1193f97a8b948b0609a3ee25c14311d74ddf8d8e69117
|
|
BLAKE2b-256 checksum How to use checksums |
364d028b3b9680913a73f050c96d2e178e8dae6895ffe7f280b41d5cb423c11a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/0.0.0 pkginfo/1.6.0 requests/2.24.0 setuptools/46.1.3.post20200330 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.2
|
Security for grAdapt 0.1.1b8
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.