Skip to content

Commit

Permalink
Several improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
holgern committed Mar 8, 2024
1 parent 0ddc83a commit bef88d6
Show file tree
Hide file tree
Showing 98 changed files with 452 additions and 444 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
build_tools/* linguist-documentation=true
.github/* linguist-documentation=true
94 changes: 94 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: CI
on:
push:
branches: [ main ]
tags: [ 'v[0-9]+\.[0-9]+.*' ]
pull_request: { branches: [main] }
workflow_call:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.9"
- uses: pre-commit/[email protected]

test1:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@master
- name: Setup Python
uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}
- name: Install packages
run: |
pip install -U pip wheel
pip install .
pip install .[dev,plots]
python -c 'import skopt; print(skopt.__version__)'
- name: Run tests
run: pytest

test2:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
scikit-learn-version: ["1.4.1.post1", "1.3.2", "1.2.2", "1.1.3", "1.0.2"]
numpy-version: ["1.20.3", "1.22.4","1.24.4", "1.26.4"]
exclude:
- python-version: "3.8"
scikit-learn-version: "1.4.1.post1"
- python-version: "3.8"
numpy-version: "1.26.4"
- python-version: "3.11"
scikit-learn-version: "1.0.2"
- python-version: "3.11"
scikit-learn-version: "1.1.3"
- python-version: "3.10"
numpy-version: "1.20.3"
- python-version: "3.11"
numpy-version: "1.20.3"
- python-version: "3.11"
numpy-version: "1.22.4"
steps:
- uses: actions/checkout@master
- name: Setup Python
uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}
- name: Install packages
run: |
pip install -U pip wheel
pip install numpy==${{ matrix.numpy-version }}
pip install scikit-learn==${{ matrix.scikit-learn-version }}
pip install .
pip install .[dev,plots]
python -c 'import skopt; print(skopt.__version__)'
- name: Run tests
run: pytest

doctest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install packages
run: |
pip install -U pip wheel
pip install .
pip install .[dev,plots,doc]
python -c 'import skopt; print(skopt.__version__)'
- name: Run doc test
run: cd doc; make doctest
20 changes: 0 additions & 20 deletions .github/workflows/doc-tests-linux.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .github/workflows/pre-commit.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/tests-all-os.yml

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/tests-linux.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ doc/modules/generated/
.vscode/
*.pkl
*.gz
*.log
# mac OS users
.DS_Store

Expand Down
2 changes: 2 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Scikit-Optimize is a community effort. Contributors include, in alphabetical ord
* [Alexander Fabisch][AlexanderFabisch]
* [Thomas Fan][thomasjpfan]
* [Tim Head][betatim]
* [kernc][kernc]
* [Manoj Kumar][mechcoder]
* [Gilles Louppe][glouppe]
* [Katie Malone][cmmalone]
Expand Down Expand Up @@ -37,3 +38,4 @@ The scikit-optimize logo was a contribution by
[mirca]: http://mirca.github.io/
[iaroslav-ai]: http://iaroslav-ai.github.io/
[holgern]: https://github.com/holgern
[kernc]: https://github.com/kernc
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Contributing
Contributing
============

Scikit-Optimize is an open-source project and contributions of all kinds
are welcome. We believe in this [code of conduct](CONDUCT.md).
Expand Down
42 changes: 26 additions & 16 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
Scikit-Optimize
===============

Scikit-Optimize, or ``skopt``, is a simple and efficient library to
minimize (very) expensive and noisy black-box functions. It implements
Scikit-Optimize, or ``skopt``, is a simple and efficient library for
optimizing (very) expensive and noisy black-box functions. It implements
several methods for sequential model-based optimization. ``skopt`` aims
to be accessible and easy to use in many contexts.

The library is built on top of NumPy, SciPy and Scikit-Learn.
The library is built on top of NumPy, SciPy, and Scikit-Learn.

We do not perform gradient-based optimization. For gradient-based
optimization algorithms look at
``scipy.optimize``
`here <http://docs.scipy.org/doc/scipy/reference/optimize.html>`_.

.. figure:: https://github.com/holgern/scikit-optimize/blob/master/media/bo-objective.png
.. figure:: https://raw.githubusercontent.com/holgern/scikit-optimize/main/media/bo-objective.png
:alt: Approximated objective

Approximated objective function after 50 iterations of ``gp_minimize``.
Expand All @@ -33,9 +33,10 @@ i decided to continue on my own. I still have credentials for pypi, so I will pu
Important links
---------------

- Static documentation - `Static
documentation <https://scikit-optimize.github.io/>`__
- Project website <https://scikit-optimize.readthedocs.io/>`__
- Example notebooks - can be found in examples_.
- `Discussion forum
<https://github.com/scikit-optimize/scikit-optimize/discussions>`__
- Issue tracker -
https://github.com/holgern/scikit-optimize/issues
- Releases - https://pypi.python.org/pypi/scikit-optimize
Expand All @@ -57,16 +58,16 @@ You can install the latest release with:

pip install scikit-optimize

This installs an essential version of scikit-optimize. To install scikit-optimize
with plotting functionality, you can instead do:
This installs the essentials. To install plotting functionality,
you can instead do:
::

pip install 'scikit-optimize[plots]'

This will install matplotlib along with scikit-optimize.
This will additionally install Matplotlib.

In addition there is a `conda-forge <https://conda-forge.org/>`_ package
of scikit-optimize:
If you're using Anaconda platform, there is a `conda-forge <https://conda-forge.org/>`_
package of scikit-optimize:
::

conda install -c conda-forge scikit-optimize
Expand Down Expand Up @@ -110,7 +111,7 @@ class:
Read our `introduction to bayesian
optimization <https://scikit-optimize.github.io/stable/auto_examples/bayesian-optimization.html>`__
optimization <https://scikit-optimize.readthedocs.io/en/latest/auto_examples/bayesian-optimization.html>`__
and the other examples_.


Expand Down Expand Up @@ -149,12 +150,14 @@ Installation
~~~~~~~~~~~~

::

pip install pre-commit


Using homebrew
~~~~~~~~~~~~~~
::

brew install pre-commit

pre-commit --version
Expand All @@ -164,19 +167,22 @@ Install the git hook scripts
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

::

pre-commit install


Run against all the files
~~~~~~~~~~~~~~~~~~~~~~~~~
::

pre-commit run --all-files
pre-commit run --show-diff-on-failure --color=always --all-files


Update package rev in pre-commit yaml
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::

pre-commit autoupdate
pre-commit run --show-diff-on-failure --color=always --all-files

Expand Down Expand Up @@ -209,7 +215,7 @@ The scikit-optimize project was made possible with the support of

.. image:: https://avatars1.githubusercontent.com/u/18165687?v=4&s=128
:alt: Wild Tree Tech
:target: http://wildtreetech.com
:target: https://wildtreetech.com

.. image:: https://i.imgur.com/lgxboT5.jpg
:alt: NYU Center for Data Science
Expand All @@ -221,7 +227,7 @@ The scikit-optimize project was made possible with the support of

.. image:: https://i.imgur.com/3enQ6S8.jpg
:alt: Northrop Grumman
:target: http://www.northropgrumman.com/Pages/default.aspx
:target: https://www.northropgrumman.com/Pages/default.aspx

If your employer allows you to work on scikit-optimize during the day and would like
recognition, feel free to add them to the "Made possible by" list.
Expand All @@ -231,9 +237,13 @@ recognition, feel free to add them to the "Made possible by" list.
:target: https://pypi.python.org/pypi/scikit-optimize
.. |conda| image:: https://anaconda.org/conda-forge/scikit-optimize/badges/version.svg
:target: https://anaconda.org/conda-forge/scikit-optimize
.. |CI Status| image:: https://github.com/holgern/scikit-optimize/actions/workflows/ci.yml/badge.svg?branch=main
:target: https://github.com/holgern/scikit-optimize/actions/workflows/ci.yml?query=branch%3Amain
.. |Logo| image:: https://avatars2.githubusercontent.com/u/18578550?v=4&s=80
.. |binder| image:: https://mybinder.org/badge.svg
:target: https://mybinder.org/v2/gh/holgern/scikit-optimize/master?filepath=examples
:target: https://mybinder.org/v2/gh/holgern/scikit-optimize/main?filepath=examples
.. |Zenodo DOI| image:: https://zenodo.org/badge/54340642.svg
:target: https://zenodo.org/badge/latestdoi/54340642
.. _examples: https://scikit-optimize.github.io/stable/auto_examples/index.html
.. |scipy.optimize| replace:: ``scipy.optimize``
.. _scipy.optimize: https://docs.scipy.org/doc/scipy/reference/optimize.html
.. _examples: https://scikit-optimize.readthedocs.io/en/latest/auto_examples/index.html
Binary file modified doc/auto_examples/auto_examples_jupyter.zip
Binary file not shown.
Binary file modified doc/auto_examples/auto_examples_python.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion doc/auto_examples/bayesian-optimization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Bayesian optimization with `skopt`\n\nGilles Louppe, Manoj Kumar July 2016.\nReformatted by Holger Nahrstaedt 2020\n\n.. currentmodule:: skopt\n\n## Problem statement\n\nWe are interested in solving\n\n\\begin{align}x^* = arg \\min_x f(x)\\end{align}\n\nunder the constraints that\n\n- $f$ is a black box for which no closed form is known\n (nor its gradients);\n- $f$ is expensive to evaluate;\n- and evaluations of $y = f(x)$ may be noisy.\n\n**Disclaimer.** If you do not have these constraints, then there\nis certainly a better optimization algorithm than Bayesian optimization.\n\nThis example uses :class:`plots.plot_gaussian_process` which is available\nsince version 0.8.\n\n## Bayesian optimization loop\n\nFor $t=1:T$:\n\n1. Given observations $(x_i, y_i=f(x_i))$ for $i=1:t$, build a\n probabilistic model for the objective $f$. Integrate out all\n possible true functions, using Gaussian process regression.\n\n2. optimize a cheap acquisition/utility function $u$ based on the\n posterior distribution for sampling the next point.\n $x_{t+1} = arg \\min_x u(x)$\n Exploit uncertainty to balance exploration against exploitation.\n\n3. Sample the next observation $y_{t+1}$ at $x_{t+1}$.\n\n\n## Acquisition functions\n\nAcquisition functions $u(x)$ specify which sample $x$: should be\ntried next:\n\n- Expected improvement (default):\n $-EI(x) = -\\mathbb{E} [f(x) - f(x_t^+)]$\n- Lower confidence bound: $LCB(x) = \\mu_{GP}(x) + \\kappa \\sigma_{GP}(x)$\n- Probability of improvement: $-PI(x) = -P(f(x) \\geq f(x_t^+) + \\kappa)$\n\nwhere $x_t^+$ is the best point observed so far.\n\nIn most cases, acquisition functions provide knobs (e.g., $\\kappa$) for\ncontrolling the exploration-exploitation trade-off.\n- Search in regions where $\\mu_{GP}(x)$ is high (exploitation)\n- Probe regions where uncertainty $\\sigma_{GP}(x)$ is high (exploration)\n"
"\n# Bayesian optimization with `skopt`\n\nGilles Louppe, Manoj Kumar July 2016.\nReformatted by Holger Nahrstaedt 2020\n\n.. currentmodule:: skopt\n\n## Problem statement\n\nWe are interested in solving\n\n\\begin{align}x^* = arg \\\\min_x f(x)\\end{align}\n\nunder the constraints that\n\n- $f$ is a black box for which no closed form is known\n (nor its gradients);\n- $f$ is expensive to evaluate;\n- and evaluations of $y = f(x)$ may be noisy.\n\n**Disclaimer.** If you do not have these constraints, then there\nis certainly a better optimization algorithm than Bayesian optimization.\n\nThis example uses :class:`plots.plot_gaussian_process` which is available\nsince version 0.8.\n\n## Bayesian optimization loop\n\nFor $t=1:T$:\n\n1. Given observations $(x_i, y_i=f(x_i))$ for $i=1:t$, build a\n probabilistic model for the objective $f$. Integrate out all\n possible true functions, using Gaussian process regression.\n\n2. optimize a cheap acquisition/utility function $u$ based on the\n posterior distribution for sampling the next point.\n $x_{t+1} = arg \\\\min_x u(x)$\n Exploit uncertainty to balance exploration against exploitation.\n\n3. Sample the next observation $y_{t+1}$ at $x_{t+1}$.\n\n\n## Acquisition functions\n\nAcquisition functions $u(x)$ specify which sample $x$: should be\ntried next:\n\n- Expected improvement (default):\n $-EI(x) = -\\\\mathbb{E} [f(x) - f(x_t^+)]$\n- Lower confidence bound: $LCB(x) = \\\\mu_{GP}(x) + \\\\kappa \\\\sigma_{GP}(x)$\n- Probability of improvement: $-PI(x) = -P(f(x) \\\\geq f(x_t^+) + \\\\kappa)$\n\nwhere $x_t^+$ is the best point observed so far.\n\nIn most cases, acquisition functions provide knobs (e.g., $\\\\kappa$) for\ncontrolling the exploration-exploitation trade-off.\n- Search in regions where $\\\\mu_{GP}(x)$ is high (exploitation)\n- Probe regions where uncertainty $\\\\sigma_{GP}(x)$ is high (exploration)\n"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion doc/auto_examples/bayesian-optimization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
r"""
==================================
Bayesian optimization with `skopt`
==================================
Expand Down
2 changes: 1 addition & 1 deletion doc/auto_examples/bayesian-optimization.py.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d7c44aa29f20fbdb1c77eecf706db4d9
7832badf66cceec028004ff84be09974
Loading

0 comments on commit bef88d6

Please sign in to comment.