Skip to content

Commit

Permalink
Merge pull request #48 from jajcayn/feature/switch_gpflow_pypi
Browse files Browse the repository at this point in the history
Feature/switch gpflow pypi
  • Loading branch information
jajcayn authored Mar 31, 2020
2 parents ba7ae42 + 6256127 commit 143080f
Show file tree
Hide file tree
Showing 8 changed files with 466 additions and 481 deletions.
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ Example of ternary partition tree after optimisation.
`GPSO` package is tested and should run without any problems on python versions 3.6 and 3.7.

### One-liner
Installation from PyPI is not possible, as `GPFlow` 2.0 is not on PyPI yet.

For those who want to optimise right away just
```bash
pip install git+https://github.com/jajcayn/pygpso
pip install pygpso
```
and go ahead! Make sure to check example notebooks in [the **examples** directory](examples/) to see how it works and what it can do. Or, alternatively, you can run interactive notebooks in binder: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jajcayn/pygpso.git/master?filepath=examples).
and go ahead! Make sure to check example notebooks in [the **examples** directory](examples/) to see how it works and what it can do. Or, alternatively, you can run interactive notebooks in binder: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jajcayn/pygpso.git/master?filepath=examples

### Go proper
When you are the type of girl or guy who likes to install packages properly, start by cloning (or forking) this repository, then installing all the dependencies and finally install the package itself
Expand All @@ -52,8 +50,7 @@ A guide on how to optimise and what can be done using this package is given as j

The basic idea is to initialise the parameter space in which the optimisation is to be run and then iteratively dig deeper and evaluate the objective function when necessary
```python
from gpso.param_space import ParameterSpace
from gpso.optimisation import GPSOptimiser
from gpso import ParameterSpace, GPSOptimiser


def objective_function(params):
Expand Down Expand Up @@ -82,9 +79,7 @@ Plotting of the ternary tree (`gpso.plotting.plot_ternary_tree()`) requires `igr
Support of saver (for saving models run, e.g. timeseries along with the optimisation) is provided by `PyTables` (and `pandas` if you're saving results to `DataFrame`s).

## Known bugs and future improvements
* currently cannot be installed through `pip` from PyPI, since `GPFlow` 2.0 is not on PyPI yet
* saving of GP surrogate is now hacky, as `GPFlow` not yet officially supports saving / loading of the models due to [bug in `tensorflow`](https://github.com/tensorflow/tensorflow/issues/34908). The hacky way, unfortunately, only supports basic kernels and mean functions, i.e. no kernel operations (such as sum or multiplication) allowed (for now).
* once `GPFlow` 2.0 is out there and supports saving, this package will be updated accordingly

## Final notes
When you encounter a bug or have any idea for an improvement, please open an issue and/or contact me.
Expand Down
163 changes: 81 additions & 82 deletions examples/0-basic-optimisation.ipynb

Large diffs are not rendered by default.

380 changes: 190 additions & 190 deletions examples/1-callbacks.ipynb

Large diffs are not rendered by default.

151 changes: 75 additions & 76 deletions examples/2-saving-model-output.ipynb

Large diffs are not rendered by default.

223 changes: 111 additions & 112 deletions examples/3-saving-resuming-optimisation.ipynb

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ matplotlib
flake8
pytest
black
gast==0.2.2 # tensorflow 2.1.0 explicitely needs gast 0.2.2
tensorflow>=2.1.0
git+https://github.com/GPflow/GPflow.git@develop#egg=gpflow
gpflow>=2.0.0
13 changes: 2 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import re
from os import path

import setuptools
Expand All @@ -10,14 +9,6 @@
with open("requirements.txt") as f:
requirements = f.read().splitlines()

checked_requirements = []
for requirement in requirements:
if requirement.startswith("git+"):
# find package name from git address
pkg_name = re.findall(r"\/([a-zA-Z]*)\.git", requirement)[0]
requirement = f"{pkg_name.lower()} @ " + requirement
checked_requirements.append(requirement)

extra_requirements = {}
with open("requirements_optional.txt") as f:
extra_reqs = f.read().splitlines()
Expand All @@ -27,7 +18,7 @@

setuptools.setup(
name="pygpso",
version="0.4",
version="0.4.1",
description="Bayesian optimisation method leveraging Gaussian Processes "
"surrogate",
long_description=long_description,
Expand All @@ -47,7 +38,7 @@
"Topic :: Scientific/Engineering :: Medical Science Apps.",
],
python_requires=">=3.6",
install_requires=checked_requirements,
install_requires=requirements,
extras_require=extra_requirements,
include_package_data=True,
)
3 changes: 3 additions & 0 deletions tests/test_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def test_init(self):


class TestCallbacks(unittest.TestCase):
_ = pytest.importorskip("igraph")
_ = pytest.importorskip("pandas")
_ = pytest.importorskip("tables")
callbacks = [
PostIterationPlotting(
filename_pattern=os.path.join(
Expand Down

0 comments on commit 143080f

Please sign in to comment.