embarrassingly
Embarrassingly obvious (in retrospect) ways to hack objective functions before you send them to optimization routines. See blog article for motivation and explanation
Install
pip install embarrassingly
Example 1 : Parallel objective computation
from embarrassingly.parallel import Parallel
import optuna
def pre_objective(worker, trial):
print('Hi this is worker ' + str(worker))
x = [trial.suggest_float('x' + str(i), 0, 1) for i in range(3)]
return x[0] + x[1] * x[2]
def test_optuna():
objective = Parallel(pre_objective, num_workers=7)
study = optuna.create_study()
study.optimize(objective, n_trials=15, n_jobs=7)
Example 2 : Plateau finding
from scipy.optimize import shgo
from embarrassingly.underpromoted import plateaudinous, Underpromoted2d
bounds = [(-1 ,1) ,(-1 ,1)]
f = plateaudinous
res1 = shgo(func=f, bounds=bounds, n=8, iters=4, options={'minimize_every_iter': True, 'ftol': 0.1})
print('Minimum at '+str(res1.x))
f_tilde = Underpromoted2d(f, bounds=bounds, radius=0.05)
res1 = shgo(func=f_tilde, bounds=bounds, n=8, iters=4, options={'minimize_every_iter': True, 'ftol': 0.1})
print('Landed at '+str(res1.x))
Example 3 : Expensive functions
See shy_shgo.py
def slow_and_pointless(x):
""" Example of a function with varying computation time """
r = np.linalg.norm(x)
quad = (0.5*0.5-r*r)/(0.5*0.5)
compute_time = max(0,0.5*quad+x[0])
time.sleep(compute_time)
return schwefel([1000*x[0],980*x[1]])[0]
# Save time by making it a "shy" objective function
bounds = [(-0.5, 0.5), (-0.5, 0.5)]
SAP = Shy(slow_and_pointless, bounds=bounds, t_unit=0.01, d_unit=0.3)
from scipy.optimize import minimize
res = scipy.optimize.shgo(func=SAP, bounds=bounds, n=8, iters=4, options={'minimize_every_iter': True, 'ftol': 0.1})
Metadata
Release files for embarrassingly 0.0.6
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 |
|---|---|---|---|---|
| embarrassingly-0.0.6.tar.gz | 10.2 kB | Without provenance | Details for embarrassingly-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| embarrassingly-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for embarrassingly-0.0.6-py3-none-any.whl |
Total release size: 22.4 kB
Release files / embarrassingly-0.0.6.tar.gz
| Download URL | embarrassingly-0.0.6.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f88fbc9459322a67d9038f35031d74b3ec70dec56a2e06fa10797b2ce18c2981
|
|
BLAKE2b-256 checksum How to use checksums |
a669eea2ebb14bbdf095b3f4a868b8562557cf4581ef80a717e2a91b1a4371a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
|
Release files / embarrassingly-0.0.6-py3-none-any.whl
| Download URL | embarrassingly-0.0.6-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe1880e50e295c28567e7d3b9b7e4ebb7218b0e5b097e2f900c17ba30485b0fd
|
|
BLAKE2b-256 checksum How to use checksums |
bf57c0be723e2b5c822a8b730beeac5689c846558d45fd25cfdd4c8fec02800d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.1
|
Security for embarrassingly 0.0.6
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.