Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Lando-L/boax
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v.0.1.2
Choose a base ref
...
head repository: Lando-L/boax
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 13 commits
  • 232 files changed
  • 1 contributor

Commits on May 15, 2024

  1. chore: bump version

    Lando-L committed May 15, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8c5d8bd View commit details

Commits on Sep 29, 2024

  1. Copy the full SHA
    7cb4281 View commit details
  2. docs: add multi-arm bandit example

    Lando-L committed Sep 29, 2024
    Copy the full SHA
    4e5f92d View commit details

Commits on Oct 4, 2024

  1. feat: parameterize test cases

    Lando-L committed Oct 4, 2024
    Copy the full SHA
    0d86e3c View commit details
  2. Copy the full SHA
    97df9ac View commit details
  3. chore: bump version

    Lando-L committed Oct 4, 2024
    Copy the full SHA
    3f58658 View commit details
  4. fix: fix renaming issues

    Lando-L committed Oct 4, 2024
    Copy the full SHA
    f545c73 View commit details

Commits on Dec 3, 2024

  1. feat: add experiments API

    Lando-L committed Dec 3, 2024
    Copy the full SHA
    c5cb886 View commit details

Commits on Dec 4, 2024

  1. fix: use q_batch generation for log poi and log ei

    Lando-L committed Dec 4, 2024
    Copy the full SHA
    5d39e01 View commit details
  2. style: fix formatting

    Lando-L committed Dec 4, 2024
    Copy the full SHA
    87ddb51 View commit details

Commits on Feb 10, 2025

  1. feat: add experiment api (#14)

    * feat: add experiment api
    
    * feat: update poetry.lock
    
    * style: format with ruff
    Lando-L authored Feb 10, 2025
    Copy the full SHA
    12d80de View commit details

Commits on Feb 11, 2025

  1. docs: update readthedocs config (#15)

    Lando-L authored Feb 11, 2025
    Copy the full SHA
    09ee27f View commit details
  2. fix: readthedocs config (#16)

    * fix: readthedocs config
    
    * fix: add missing dependency for book theme
    
    * fix: readthedocs build command
    Lando-L authored Feb 11, 2025
    Copy the full SHA
    ceac931 View commit details
Showing with 10,534 additions and 5,407 deletions.
  1. +16 −5 .github/workflows/python-publish.yml
  2. +31 −12 .github/workflows/tests.yml
  3. +7 −11 .readthedocs.yml
  4. +79 −56 README.md
  5. +3 −2 boax/__init__.py
  6. +2 −9 boax/{optimization → }/acquisitions/__init__.py
  7. +605 −0 boax/acquisitions/alias.py
  8. +12 −6 boax/{optimization → }/acquisitions/base.py
  9. 0 boax/{optimization → }/acquisitions/functions/__init__.py
  10. +14 −20 boax/{optimization → }/acquisitions/functions/analytic.py
  11. +5 −0 boax/{optimization → }/acquisitions/functions/monte_carlo.py
  12. +18 −0 boax/acquisitions/surrogates/__init__.py
  13. +186 −0 boax/acquisitions/surrogates/alias.py
  14. +60 −0 boax/acquisitions/surrogates/base.py
  15. +4 −1 boax/core/__init__.py
  16. +0 −2 boax/core/distributions/__init__.py
  17. +18 −5 boax/core/distributions/multivariate_normal.py
  18. +18 −4 boax/core/distributions/normal.py
  19. +0 −54 boax/core/distributions/transformed.py
  20. +1 −5 boax/{prediction → core}/models/__init__.py
  21. +3 −3 boax/{prediction → core}/models/base.py
  22. 0 boax/{prediction → core}/models/functions/__init__.py
  23. +12 −36 boax/{prediction → core}/models/functions/gaussian.py
  24. +2 −2 boax/{prediction → core}/models/functions/multi_fidelity.py
  25. +222 −0 boax/core/models/gaussian_process.py
  26. +1 −5 boax/{prediction → core}/models/kernels/__init__.py
  27. +15 −50 boax/{prediction → core}/models/kernels/alias.py
  28. 0 boax/{prediction → core}/models/kernels/base.py
  29. +0 −2 boax/{prediction → core}/models/kernels/functions/__init__.py
  30. +17 −10 boax/{prediction → core}/models/kernels/functions/distance.py
  31. +5 −5 boax/{prediction → core}/models/kernels/functions/matern.py
  32. +3 −3 boax/{prediction → core}/models/kernels/functions/rbf.py
  33. +4 −3 boax/{optimization → core/models/kernels/transformations}/__init__.py
  34. +16 −52 boax/{prediction/models/kernels/transformed.py → core/models/kernels/transformations/alias.py}
  35. 0 boax/{prediction → core}/models/likelihoods/__init__.py
  36. +2 −2 boax/{prediction → core}/models/likelihoods/alias.py
  37. 0 boax/{prediction → core}/models/likelihoods/base.py
  38. 0 boax/{prediction → core}/models/likelihoods/functions/__init__.py
  39. 0 boax/{prediction → core}/models/likelihoods/functions/conditional.py
  40. 0 boax/{prediction → core}/models/likelihoods/functions/marginal.py
  41. 0 boax/{prediction → core}/models/means/__init__.py
  42. +20 −9 boax/{prediction → core}/models/means/alias.py
  43. +5 −5 boax/{prediction → core}/models/means/base.py
  44. +23 −0 boax/core/models/transformations/__init__.py
  45. +104 −0 boax/core/models/transformations/alias.py
  46. +62 −0 boax/core/models/transformations/base.py
  47. +25 −0 boax/core/models/transformations/input.py
  48. +13 −12 boax/{prediction/models/kernels/functions/periodic.py → core/models/transformations/outcome.py}
  49. +44 −0 boax/core/models/transformations/utils.py
  50. +1 −1 boax/{prediction → core}/objectives/__init__.py
  51. +1 −1 boax/{prediction → core}/objectives/alias.py
  52. 0 boax/{prediction → core}/objectives/base.py
  53. +2 −3 boax/{version.py → core/objectives/transformations/__init__.py}
  54. +7 −9 boax/{prediction/objectives/transformed.py → core/objectives/transformations/alias.py}
  55. 0 boax/{optimization → core}/optimizers/__init__.py
  56. +8 −8 boax/{optimization → core}/optimizers/alias.py
  57. +6 −2 boax/{optimization → core}/optimizers/base.py
  58. 0 boax/{optimization → core}/optimizers/initializers/__init__.py
  59. +17 −34 boax/{optimization → core}/optimizers/initializers/alias.py
  60. +3 −1 boax/{optimization → core}/optimizers/initializers/base.py
  61. 0 boax/{optimization → core}/optimizers/solvers/__init__.py
  62. +8 −15 boax/{optimization → core}/optimizers/solvers/alias.py
  63. +5 −1 boax/{optimization → core}/optimizers/solvers/base.py
  64. +2 −0 boax/core/samplers/__init__.py
  65. +144 −57 boax/core/samplers/alias.py
  66. +10 −10 boax/core/samplers/base.py
  67. +0 −1 boax/core/samplers/functions/__init__.py
  68. +0 −29 boax/core/samplers/functions/iid.py
  69. +1 −4 boax/core/samplers/functions/utils.py
  70. +21 −0 boax/experiments/__init__.py
  71. +166 −0 boax/experiments/alias.py
  72. +84 −0 boax/experiments/base.py
  73. +24 −0 boax/experiments/benchmarks/__init__.py
  74. +67 −0 boax/experiments/benchmarks/alias.py
  75. +36 −0 boax/experiments/benchmarks/base.py
  76. +84 −0 boax/experiments/benchmarks/functions.py
  77. +3 −3 boax/{prediction → experiments/functions}/__init__.py
  78. +70 −0 boax/experiments/functions/bandit.py
  79. +113 −0 boax/experiments/functions/optimization.py
  80. +23 −0 boax/experiments/search_spaces/__init__.py
  81. +14 −16 boax/{prediction/models/kernels/functions/utils.py → experiments/search_spaces/base.py}
  82. +23 −0 boax/experiments/search_spaces/parameters/__init__.py
  83. +61 −0 boax/experiments/search_spaces/parameters/alias.py
  84. +114 −0 boax/experiments/search_spaces/parameters/utils.py
  85. +149 −0 boax/experiments/search_spaces/utils.py
  86. +0 −394 boax/optimization/acquisitions/alias.py
  87. +0 −130 boax/optimization/acquisitions/constraints/alias.py
  88. +0 −67 boax/optimization/acquisitions/transformed.py
  89. +7 −6 boax/{optimization/acquisitions/constraints → policies}/__init__.py
  90. +132 −0 boax/policies/alias.py
  91. +12 −10 boax/{optimization/acquisitions/constraints → policies}/base.py
  92. +21 −0 boax/policies/believes/__init__.py
  93. +117 −0 boax/policies/believes/alias.py
  94. +90 −0 boax/policies/believes/base.py
  95. +0 −205 boax/prediction/models/gaussian_process.py
  96. +0 −154 boax/prediction/models/transformed.py
  97. +1 −1 boax/utils/__init__.py
  98. +0 −186 boax/utils/functools.py
  99. +127 −0 boax/utils/math.py
  100. +1 −0 boax/utils/typing.py
  101. +67 −0 docs/source/api_reference/boax.acquisitions.rst
  102. +113 −0 docs/source/api_reference/boax.core.distributions.rst
  103. +53 −37 docs/source/api_reference/{boax.prediction.rst → boax.core.models.rst}
  104. +50 −0 docs/source/api_reference/boax.core.objectives.rst
  105. +91 −0 docs/source/api_reference/boax.core.optimizers.rst
  106. +8 −160 docs/source/api_reference/boax.core.rst
  107. +36 −0 docs/source/api_reference/boax.core.samplers.rst
  108. +16 −0 docs/source/api_reference/boax.experiments.rst
  109. +0 −172 docs/source/api_reference/boax.optimization.rst
  110. +64 −0 docs/source/api_reference/boax.policies.rst
  111. +6 −0 docs/source/api_reference/generated/boax.acquisitions.expected_improvement.rst
  112. +6 −0 docs/source/api_reference/generated/boax.acquisitions.log_expected_improvement.rst
  113. +6 −0 docs/source/api_reference/generated/boax.acquisitions.log_probability_of_improvement.rst
  114. +6 −0 docs/source/api_reference/generated/boax.acquisitions.probability_of_improvement.rst
  115. +6 −0 docs/source/api_reference/generated/boax.acquisitions.q_expected_improvement.rst
  116. +6 −0 docs/source/api_reference/generated/boax.acquisitions.q_probability_of_improvement.rst
  117. +6 −0 docs/source/api_reference/generated/boax.acquisitions.q_upper_confidence_bound.rst
  118. +6 −0 docs/source/api_reference/generated/boax.acquisitions.surrogates.single_task_gaussian_process.rst
  119. +6 −0 docs/source/api_reference/generated/boax.acquisitions.upper_confidence_bound.rst
  120. +0 −6 docs/source/api_reference/generated/boax.core.distributions.mvn_to_norm.rst
  121. +0 −6 docs/source/api_reference/generated/boax.core.distributions.norm_to_mvn.rst
  122. +6 −0 docs/source/api_reference/generated/boax.core.models.gaussian_process.exact.rst
  123. +6 −0 docs/source/api_reference/generated/boax.core.models.kernels.matern_five_halves.rst
  124. +6 −0 docs/source/api_reference/generated/boax.core.models.kernels.matern_one_half.rst
  125. +6 −0 docs/source/api_reference/generated/boax.core.models.kernels.matern_three_halves.rst
  126. +6 −0 docs/source/api_reference/generated/boax.core.models.kernels.rbf.rst
  127. +6 −0 docs/source/api_reference/generated/boax.core.models.kernels.transformations.additive.rst
  128. +6 −0 docs/source/api_reference/generated/boax.core.models.kernels.transformations.product.rst
  129. +6 −0 docs/source/api_reference/generated/boax.core.models.kernels.transformations.scaled.rst
  130. +6 −0 docs/source/api_reference/generated/boax.core.models.likelihoods.beta.rst
  131. +6 −0 docs/source/api_reference/generated/boax.core.models.likelihoods.gaussian.rst
  132. +6 −0 docs/source/api_reference/generated/boax.core.models.means.constant.rst
  133. +6 −0 docs/source/api_reference/generated/boax.core.models.means.linear.rst
  134. +6 −0 docs/source/api_reference/generated/boax.core.models.means.zero.rst
  135. +6 −0 docs/source/api_reference/generated/boax.core.models.transformations.joined.rst
  136. +6 −0 docs/source/api_reference/generated/boax.core.models.transformations.transformed.rst
  137. +6 −0 docs/source/api_reference/generated/boax.core.objectives.negative_log_likelihood.rst
  138. +6 −0 docs/source/api_reference/generated/boax.core.objectives.transformations.penalized.rst
  139. +6 −0 docs/source/api_reference/generated/boax.core.optimizers.batch.rst
  140. +6 −0 docs/source/api_reference/generated/boax.core.optimizers.initializers.q_batch.rst
  141. +6 −0 docs/source/api_reference/generated/boax.core.optimizers.initializers.q_batch_nonnegative.rst
  142. +6 −0 docs/source/api_reference/generated/boax.core.optimizers.sequential.rst
  143. +6 −0 docs/source/api_reference/generated/boax.core.optimizers.solvers.scipy.rst
  144. +6 −0 docs/source/api_reference/generated/boax.experiments.bandit.rst
  145. +6 −0 docs/source/api_reference/generated/boax.experiments.optimization.rst
  146. +0 −6 docs/source/api_reference/generated/boax.optimization.acquisitions.constrained.rst
  147. +0 −6 docs/source/api_reference/generated/boax.optimization.acquisitions.constraints.greater_or_equal.rst
  148. +0 −6 docs/source/api_reference/generated/boax.optimization.acquisitions.constraints.less_or_equal.rst
  149. +0 −6 ...ource/api_reference/generated/boax.optimization.acquisitions.constraints.log_greater_or_equal.rst
  150. +0 −6 docs/source/api_reference/generated/boax.optimization.acquisitions.constraints.log_less_or_equal.rst
  151. +0 −6 docs/source/api_reference/generated/boax.optimization.acquisitions.expected_improvement.rst
  152. +0 −6 docs/source/api_reference/generated/boax.optimization.acquisitions.log_constrained.rst
  153. +0 −6 docs/source/api_reference/generated/boax.optimization.acquisitions.log_expected_improvement.rst
  154. +0 −6 .../source/api_reference/generated/boax.optimization.acquisitions.log_probability_of_improvement.rst
  155. +0 −6 docs/source/api_reference/generated/boax.optimization.acquisitions.posterior_mean.rst
  156. +0 −6 docs/source/api_reference/generated/boax.optimization.acquisitions.posterior_scale.rst
  157. +0 −6 docs/source/api_reference/generated/boax.optimization.acquisitions.probability_of_improvement.rst
  158. +0 −6 docs/source/api_reference/generated/boax.optimization.acquisitions.q_expected_improvement.rst
  159. +0 −6 docs/source/api_reference/generated/boax.optimization.acquisitions.q_knowledge_gradient.rst
  160. +0 −6 docs/source/api_reference/generated/boax.optimization.acquisitions.q_probability_of_improvement.rst
  161. +0 −6 docs/source/api_reference/generated/boax.optimization.acquisitions.q_upper_confidence_bound.rst
  162. +0 −6 docs/source/api_reference/generated/boax.optimization.acquisitions.upper_confidence_bound.rst
  163. +0 −6 docs/source/api_reference/generated/boax.optimization.optimizers.batch.rst
  164. +0 −6 docs/source/api_reference/generated/boax.optimization.optimizers.initializers.q_batch.rst
  165. +0 −6 .../source/api_reference/generated/boax.optimization.optimizers.initializers.q_batch_nonnegative.rst
  166. +0 −6 docs/source/api_reference/generated/boax.optimization.optimizers.sequential.rst
  167. +0 −6 docs/source/api_reference/generated/boax.optimization.optimizers.solvers.scipy.rst
  168. +6 −0 docs/source/api_reference/generated/boax.policies.believes.binary.rst
  169. +6 −0 docs/source/api_reference/generated/boax.policies.believes.continuous.rst
  170. +6 −0 docs/source/api_reference/generated/boax.policies.boltzmann.rst
  171. +6 −0 docs/source/api_reference/generated/boax.policies.epsilon_greedy.rst
  172. +6 −0 docs/source/api_reference/generated/boax.policies.thompson_sampling.rst
  173. +6 −0 docs/source/api_reference/generated/boax.policies.upper_confidence_bound.rst
  174. +0 −6 docs/source/api_reference/generated/boax.prediction.models.gaussian_process.exact.rst
  175. +0 −6 docs/source/api_reference/generated/boax.prediction.models.gaussian_process.multi_fidelity.rst
  176. +0 −6 docs/source/api_reference/generated/boax.prediction.models.input_transformed.rst
  177. +0 −6 docs/source/api_reference/generated/boax.prediction.models.joined.rst
  178. +0 −6 docs/source/api_reference/generated/boax.prediction.models.kernels.additive.rst
  179. +0 −6 docs/source/api_reference/generated/boax.prediction.models.kernels.linear_truncated.rst
  180. +0 −6 docs/source/api_reference/generated/boax.prediction.models.kernels.matern_five_halves.rst
  181. +0 −6 docs/source/api_reference/generated/boax.prediction.models.kernels.matern_one_half.rst
  182. +0 −6 docs/source/api_reference/generated/boax.prediction.models.kernels.matern_three_halves.rst
  183. +0 −6 docs/source/api_reference/generated/boax.prediction.models.kernels.periodic.rst
  184. +0 −6 docs/source/api_reference/generated/boax.prediction.models.kernels.product.rst
  185. +0 −6 docs/source/api_reference/generated/boax.prediction.models.kernels.rbf.rst
  186. +0 −6 docs/source/api_reference/generated/boax.prediction.models.kernels.scaled.rst
  187. +0 −6 docs/source/api_reference/generated/boax.prediction.models.likelihoods.beta.rst
  188. +0 −6 docs/source/api_reference/generated/boax.prediction.models.likelihoods.gaussian.rst
  189. +0 −6 docs/source/api_reference/generated/boax.prediction.models.means.constant.rst
  190. +0 −6 docs/source/api_reference/generated/boax.prediction.models.means.linear.rst
  191. +0 −6 docs/source/api_reference/generated/boax.prediction.models.means.zero.rst
  192. +0 −6 docs/source/api_reference/generated/boax.prediction.models.outcome_transformed.rst
  193. +0 −6 docs/source/api_reference/generated/boax.prediction.models.sampled.rst
  194. +0 −6 docs/source/api_reference/generated/boax.prediction.models.scaled.rst
  195. +0 −6 docs/source/api_reference/generated/boax.prediction.objectives.negative_log_likelihood.rst
  196. +0 −6 docs/source/api_reference/generated/boax.prediction.objectives.penalized.rst
  197. +3 −2 docs/source/api_reference/index.rst
  198. +1 −1 docs/source/conf.py
  199. +180 −0 docs/source/guides/Bandit_Optimization.ipynb
  200. +0 −553 docs/source/guides/Batched_Optimization.ipynb
  201. +0 −576 docs/source/guides/Constrained_Optimization.ipynb
  202. +0 −607 docs/source/guides/Fitting_With_Priors.ipynb
  203. +87 −418 docs/source/guides/Getting_Started.ipynb
  204. +234 −0 docs/source/guides/Hyperparameter_Tuning.ipynb
  205. +2 −3 docs/source/guides/index.rst
  206. +27 −9 docs/source/index.rst
  207. +3,976 −0 poetry.lock
  208. +42 −31 pyproject.toml
  209. +326 −0 tests/acquisitions/acquisitions_test.py
  210. +89 −0 tests/core/models/gaussian_process_test.py
  211. +220 −0 tests/core/models/kernels_test.py
  212. +41 −0 tests/core/models/likelihoods_test.py
  213. +76 −0 tests/core/models/means_test.py
  214. +86 −0 tests/core/models/transformations_test.py
  215. +80 −0 tests/core/objectives/objectives_test.py
  216. +107 −0 tests/core/optimizers/initializers_test.py
  217. +111 −0 tests/core/optimizers/optimizers_test.py
  218. +40 −0 tests/core/optimizers/solvers_test.py
  219. +137 −43 tests/core/samplers_test.py
  220. +339 −0 tests/experiments/search_spaces_test.py
  221. +0 −158 tests/optimization/acquisitions/acquisitions_test.py
  222. +0 −32 tests/optimization/acquisitions/constraints_test.py
  223. +0 −52 tests/optimization/optimizers/initializers_test.py
  224. +0 −43 tests/optimization/optimizers/optimizers_test.py
  225. +0 −32 tests/optimization/optimizers/solvers_test.py
  226. +77 −0 tests/policies/believes_test.py
  227. +69 −0 tests/policies/policies_test.py
  228. +0 −154 tests/prediction/models/gaussian_process_test.py
  229. +0 −173 tests/prediction/models/kernels_test.py
  230. +0 −28 tests/prediction/models/likelihoods_test.py
  231. +0 −40 tests/prediction/models/means_test.py
  232. +0 −62 tests/prediction/objectives/objectives_test.py
21 changes: 16 additions & 5 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -26,11 +26,22 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
- name: Install poetry
uses: abatilo/actions-poetry@v4
with:
poetry-version: '2.0.1'
- name: Setup a local virtual environment
run: |
python -m pip install --upgrade pip
pip install setuptools build wheel twine
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- name: Define a cache for the virtual environment based on the dependencies lock file
uses: actions/cache@v3
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install the project dependencies
run: poetry install --only main
- name: Build package
run: python -m build
run: poetry build
- name: Publish package
run: twine upload -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} dist/*
run: poetry publish -u __token__ -p ${{ secrets.PYPI_API_TOKEN }}
43 changes: 31 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -21,18 +21,37 @@ permissions:

jobs:
test:
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13"]
poetry-version: ["2.0.1"]
os: [ubuntu-latest]

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[tests]
- name: Test with pytest
run: pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=boax --cov-report=xml --cov-report=html
- uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
uses: abatilo/actions-poetry@v4
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Setup a local virtual environment
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- name: Define a cache for the virtual environment based on the dependencies lock file
uses: actions/cache@v3
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install the project dependencies
run: poetry install --with dev,tests
- name: Static code analysis with ruff
run: poetry run ruff check boax tests
- name: Test with pytest
run: poetry run pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=boax --cov-report=xml --cov-report=html
18 changes: 7 additions & 11 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -4,17 +4,13 @@ build:
os: "ubuntu-22.04"
tools:
python: "3.11"

python:
install:
# Equivalent to 'pip install .'
- method: pip
path: .
# Equivalent to 'pip install .[docs]'
- method: pip
path: .
extra_requirements:
- docs
jobs:
install:
- pip install poetry
- poetry install --with docs
build:
html:
- poetry run python -m sphinx -T -b html -d _build/doctrees -D language=en docs/source $READTHEDOCS_OUTPUT/html

sphinx:
configuration: docs/source/conf.py
135 changes: 79 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -12,17 +12,28 @@

## Overview

Boax is a composable library of core components for Bayesian Optimization that is **designed for flexibility**. It comes with low-level interfaces for:
Boax is a composable library of core components for Bayesian Optimization
that is **designed for flexibility**.

It comes with high-level interfaces for:
* **Experiments** (`boax.experiments`):
* Bayesian Optimization Setups
* Bandit Optimization Setups
* Search Spaces

And with low-level interfaces for:
* **Constructing acquisition functions** (`boax.acquisition`):
* Acquisition Functions
* Surrogate Models
* **Constructing policy functions** (`boax.policies`):
* Policy Functions
* Believes
* **Core capabilities** (`boax.core`):
* Common Distributions
* Monte-Carlo Samplers
* **Fitting a surrogate model to data** (`boax.prediction`):
* Model Functions
* Gaussian Process Models
* Objective Functions
* **Constructing and optimizing acquisition functions** (`boax.optimization`):
* Acquisition Functions
* Optimizer Functions
* Quasi-Newton Optimizers
* Monte-Carlo Samplers

## Installation

@@ -40,63 +51,76 @@ pip install git+https://github.com/Lando-L/boax.git

## Basic Usage

Here is a basic example of using the Boax API for defining a Gaussian Process model, constructing an Acquisition function, and generating the next batch of data points to query. For more details check out the [docs](https://boax.readthedocs.io/en/latest/).
Here is a basic example of using the Boax for hyperparamter tuning.
For more details check out the [docs](https://boax.readthedocs.io/en/latest/).

1. Defining a Gaussian Process model:
1. Setting up classification task:

```python
from boax.prediction import models

model = models.gaussian_process.exact(
models.means.zero(),
models.kernels.scaled(
models.kernels.rbf(1.0), 0.5
),
models.likelihoods.gaussian(1e-4),
x_train,
y_train,
)
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVC

iris = load_iris()
X = iris.data
y = iris.target

X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)

def evaluate(C, gamma):
svc = SVC(C=C, gamma=gamma, kernel='rbf')
svc.fit(X_train, y_train)
return svc.score(X_test, y_test)
```

2. Constructing an Acquisition function.
2. Setting up a bayesian optimization experiment.

```python
from jax import vmap
from boax.optimization import acquisitions

acqf = models.outcome_transformed(
vmap(model),
acquisitions.upper_confidence_bound(2.0)
)
from jax import config
config.update("jax_enable_x64", True)
from boax.experiments import optimization

experiment = optimization(
parameters=[
{
'name': 'C',
'type': 'log_range',
'bounds': [1, 1_000],
},
{
'name': 'gamma',
'type': 'log_range',
'bounds': [1e-4, 1e-3],
},
],
batch_size=4,
)
```

3. Generating the next batch of data points to query.
3. Running the trial for N = 25 steps.

```python
from jax import numpy as jnp
from jax import random
from boax.core import distributions, samplers
from boax.optimization import optimizers

key = random.key(0)

batch_size, num_results, num_restarts = 1, 100, 10
bounds = jnp.array([[-1.0, 1.0]])

sampler = samplers.halton_uniform(
distributions.uniform.uniform(bounds[:, 0], bounds[:, 1])
)

optimizer = optimizers.batch(
optimizers.initializers.q_batch(
acqf, sampler, batch_size, num_results, num_restarts,
),
optimizers.solvers.scipy(
acqf, bounds,
),
)

next_x, value = optimizer(key)
step, results = None, []

for _ in range(25):
# Retrieve next parameterizations to evaluate
step, parameterizations = experiment.next(step, results)

# Evaluate parameterizations
evaluations = [
evaluate(**parameterization)
for parameterization in parameterizations
]

results = list(
zip(parameterizations, evaluations)
)

# Predicted best
experiment.best(step)
```

## Citing Boax
@@ -108,10 +132,9 @@ To cite Boax please use the citation:
author = {Lando L{\"o}per},
title = {{B}oax: A Bayesian Optimization library for {JAX}},
url = {https://github.com/Lando-L/boax},
version = {0.1.2},
version = {0.2.0},
year = {2023},
}
```

In the above bibtex entry, the version number
is intended to be that from [boax/version.py](https://github.com/Lando-L/boax/blob/main/boax/version.py), and the year corresponds to the project's open-source release.
In the above bibtex entry, the version number is intended to be the latest, and the year corresponds to the project's open-source release.
5 changes: 3 additions & 2 deletions boax/__init__.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@

"""The boax API."""

from . import acquisitions as acquisitions
from . import core as core
from . import optimization as optimization
from . import prediction as prediction
from . import experiments as experiments
from . import policies as policies
from . import utils as utils
Original file line number Diff line number Diff line change
@@ -14,23 +14,16 @@

"""The acquisitions sub-package."""

from . import constraints as constraints
from . import surrogates as surrogates
from .alias import expected_improvement as expected_improvement
from .alias import log_expected_improvement as log_expected_improvement
from .alias import (
log_probability_of_improvement as log_probability_of_improvement,
)
from .alias import posterior_mean as posterior_mean
from .alias import posterior_scale as posterior_scale
from .alias import probability_of_improvement as probability_of_improvement
from .alias import q_expected_improvement as q_expected_improvement
from .alias import q_knowledge_gradient as q_knowledge_gradient
from .alias import (
q_multi_fidelity_knowledge_gradient as q_multi_fidelity_knowledge_gradient,
)
from .alias import q_log_expected_improvement as q_log_expected_improvement
from .alias import q_probability_of_improvement as q_probability_of_improvement
from .alias import q_upper_confidence_bound as q_upper_confidence_bound
from .alias import upper_confidence_bound as upper_confidence_bound
from .base import Acquisition as Acquisition
from .transformed import constrained as constrained
from .transformed import log_constrained as log_constrained
Loading