| Crates.io | egobox |
| lib.rs | egobox |
| version | 0.32.0 |
| created_at | 2022-04-20 13:10:30.272349+00 |
| updated_at | 2025-08-22 13:51:02.921488+00 |
| description | A python binding for egobox crates |
| homepage | https://github.com/relf/egobox |
| repository | https://github.com/relf/egobox/python |
| max_upload_size | |
| id | 570966 |
| size | 580,863 |
egobox package is the Python binding of the optimizer named Egor and the surrogate model Gpx, mixture of Gaussian processes, from the EGObox libraries written in Rust.
pip install egobox
import numpy as np
import egobox as egx
# Objective function
def f_obj(x: np.ndarray) -> np.ndarray:
return (x - 3.5) * np.sin((x - 3.5) / (np.pi))
# Minimize f_opt in [0, 25]
res = egx.Egor([[0.0, 25.0]], seed=42).minimize(f_obj, max_iters=20)
print(f"Optimization f={res.y_opt} at {res.x_opt}") # Optimization f=[-15.12510323] at [18.93525454]
import numpy as np
import matplotlib.pyplot as plt
import egobox as egx
# Training
xtrain = np.array([0.0, 1.0, 2.0, 3.0, 4.0])
ytrain = np.array([0.0, 1.0, 1.5, 0.9, 1.0])
gpx = egx.Gpx.builder().fit(xtrain, ytrain)
# Prediction
xtest = np.linspace(0, 4, 100).reshape((-1, 1))
ytest = gpx.predict(xtest)
# Plot
plt.plot(xtest, ytest)
plt.plot(xtrain, ytrain, "o")
plt.show()
See the tutorial notebooks and examples folder for more information on the usage of the optimizer and mixture of Gaussian processes surrogate model.