redsho 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- redsho-0.1.0/.gitignore +219 -0
- redsho-0.1.0/.python-version +1 -0
- redsho-0.1.0/LICENSE +18 -0
- redsho-0.1.0/PKG-INFO +67 -0
- redsho-0.1.0/README.md +55 -0
- redsho-0.1.0/demo_visualization.png +0 -0
- redsho-0.1.0/landing_page_demo.gif +0 -0
- redsho-0.1.0/pyproject.toml +27 -0
- redsho-0.1.0/src/redsho/__init__.py +0 -0
- redsho-0.1.0/src/redsho/demo.py +149 -0
- redsho-0.1.0/src/redsho/optimizer.py +261 -0
- redsho-0.1.0/src/redsho/test_optimizer.py +96 -0
- redsho-0.1.0/src/redsho/test_toolblox.py +30 -0
- redsho-0.1.0/src/redsho/toolbox.py +80 -0
- redsho-0.1.0/uv.lock +516 -0
redsho-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# ---> Python
|
|
2
|
+
# Byte-compiled / optimized / DLL files
|
|
3
|
+
__pycache__/
|
|
4
|
+
*.py[codz]
|
|
5
|
+
*$py.class
|
|
6
|
+
|
|
7
|
+
# C extensions
|
|
8
|
+
*.so
|
|
9
|
+
|
|
10
|
+
# Distribution / packaging
|
|
11
|
+
.Python
|
|
12
|
+
build/
|
|
13
|
+
develop-eggs/
|
|
14
|
+
dist/
|
|
15
|
+
downloads/
|
|
16
|
+
eggs/
|
|
17
|
+
.eggs/
|
|
18
|
+
lib/
|
|
19
|
+
lib64/
|
|
20
|
+
parts/
|
|
21
|
+
sdist/
|
|
22
|
+
var/
|
|
23
|
+
wheels/
|
|
24
|
+
share/python-wheels/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
.installed.cfg
|
|
27
|
+
*.egg
|
|
28
|
+
MANIFEST
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
# Usually these files are written by a python script from a template
|
|
32
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
33
|
+
*.manifest
|
|
34
|
+
*.spec
|
|
35
|
+
|
|
36
|
+
# Installer logs
|
|
37
|
+
pip-log.txt
|
|
38
|
+
pip-delete-this-directory.txt
|
|
39
|
+
|
|
40
|
+
# Unit test / coverage reports
|
|
41
|
+
htmlcov/
|
|
42
|
+
.tox/
|
|
43
|
+
.nox/
|
|
44
|
+
.coverage
|
|
45
|
+
.coverage.*
|
|
46
|
+
.cache
|
|
47
|
+
nosetests.xml
|
|
48
|
+
coverage.xml
|
|
49
|
+
*.cover
|
|
50
|
+
*.py.cover
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
53
|
+
cover/
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
db.sqlite3-journal
|
|
64
|
+
|
|
65
|
+
# Flask stuff:
|
|
66
|
+
instance/
|
|
67
|
+
.webassets-cache
|
|
68
|
+
|
|
69
|
+
# Scrapy stuff:
|
|
70
|
+
.scrapy
|
|
71
|
+
|
|
72
|
+
# Sphinx documentation
|
|
73
|
+
docs/_build/
|
|
74
|
+
|
|
75
|
+
# PyBuilder
|
|
76
|
+
.pybuilder/
|
|
77
|
+
target/
|
|
78
|
+
|
|
79
|
+
# Jupyter Notebook
|
|
80
|
+
.ipynb_checkpoints
|
|
81
|
+
|
|
82
|
+
# IPython
|
|
83
|
+
profile_default/
|
|
84
|
+
ipython_config.py
|
|
85
|
+
|
|
86
|
+
# pyenv
|
|
87
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
88
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
89
|
+
# .python-version
|
|
90
|
+
|
|
91
|
+
# pipenv
|
|
92
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
93
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
94
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
95
|
+
# install all needed dependencies.
|
|
96
|
+
# Pipfile.lock
|
|
97
|
+
|
|
98
|
+
# UV
|
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
101
|
+
# commonly ignored for libraries.
|
|
102
|
+
# uv.lock
|
|
103
|
+
|
|
104
|
+
# poetry
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
106
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
107
|
+
# commonly ignored for libraries.
|
|
108
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
109
|
+
# poetry.lock
|
|
110
|
+
# poetry.toml
|
|
111
|
+
|
|
112
|
+
# pdm
|
|
113
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
114
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
115
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
116
|
+
# pdm.lock
|
|
117
|
+
# pdm.toml
|
|
118
|
+
.pdm-python
|
|
119
|
+
.pdm-build/
|
|
120
|
+
|
|
121
|
+
# pixi
|
|
122
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
123
|
+
# pixi.lock
|
|
124
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
125
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
126
|
+
.pixi
|
|
127
|
+
|
|
128
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
129
|
+
__pypackages__/
|
|
130
|
+
|
|
131
|
+
# Celery stuff
|
|
132
|
+
celerybeat-schedule
|
|
133
|
+
celerybeat.pid
|
|
134
|
+
|
|
135
|
+
# Redis
|
|
136
|
+
*.rdb
|
|
137
|
+
*.aof
|
|
138
|
+
*.pid
|
|
139
|
+
|
|
140
|
+
# RabbitMQ
|
|
141
|
+
mnesia/
|
|
142
|
+
rabbitmq/
|
|
143
|
+
rabbitmq-data/
|
|
144
|
+
|
|
145
|
+
# ActiveMQ
|
|
146
|
+
activemq-data/
|
|
147
|
+
|
|
148
|
+
# SageMath parsed files
|
|
149
|
+
*.sage.py
|
|
150
|
+
|
|
151
|
+
# Environments
|
|
152
|
+
.env
|
|
153
|
+
.envrc
|
|
154
|
+
.venv
|
|
155
|
+
env/
|
|
156
|
+
venv/
|
|
157
|
+
ENV/
|
|
158
|
+
env.bak/
|
|
159
|
+
venv.bak/
|
|
160
|
+
|
|
161
|
+
# Spyder project settings
|
|
162
|
+
.spyderproject
|
|
163
|
+
.spyproject
|
|
164
|
+
|
|
165
|
+
# Rope project settings
|
|
166
|
+
.ropeproject
|
|
167
|
+
|
|
168
|
+
# mkdocs documentation
|
|
169
|
+
/site
|
|
170
|
+
|
|
171
|
+
# mypy
|
|
172
|
+
.mypy_cache/
|
|
173
|
+
.dmypy.json
|
|
174
|
+
dmypy.json
|
|
175
|
+
|
|
176
|
+
# Pyre type checker
|
|
177
|
+
.pyre/
|
|
178
|
+
|
|
179
|
+
# pytype static type analyzer
|
|
180
|
+
.pytype/
|
|
181
|
+
|
|
182
|
+
# Cython debug symbols
|
|
183
|
+
cython_debug/
|
|
184
|
+
|
|
185
|
+
# PyCharm
|
|
186
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
187
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
188
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
189
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
190
|
+
# .idea/
|
|
191
|
+
|
|
192
|
+
# Abstra
|
|
193
|
+
# Abstra is an AI-powered process automation framework.
|
|
194
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
195
|
+
# Learn more at https://abstra.io/docs
|
|
196
|
+
.abstra/
|
|
197
|
+
|
|
198
|
+
# Visual Studio Code
|
|
199
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
200
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
201
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
202
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
203
|
+
# .vscode/
|
|
204
|
+
|
|
205
|
+
# Ruff stuff:
|
|
206
|
+
.ruff_cache/
|
|
207
|
+
|
|
208
|
+
# PyPI configuration file
|
|
209
|
+
.pypirc
|
|
210
|
+
|
|
211
|
+
# Marimo
|
|
212
|
+
marimo/_static/
|
|
213
|
+
marimo/_lsp/
|
|
214
|
+
__marimo__/
|
|
215
|
+
|
|
216
|
+
# Streamlit
|
|
217
|
+
.streamlit/secrets.toml
|
|
218
|
+
|
|
219
|
+
reports/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
redsho-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 brohrer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
6
|
+
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
|
9
|
+
following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
12
|
+
portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
15
|
+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
|
16
|
+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
18
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
redsho-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: redsho
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: robust evolutionary direction set hyperparameter optimizer
|
|
5
|
+
Author-email: Brandon Rohrer <brohrer@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.12
|
|
9
|
+
Requires-Dist: matplotlib>=3.11.1
|
|
10
|
+
Requires-Dist: numpy>=2.5.2
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# redsho
|
|
14
|
+
|
|
15
|
+
Robust Evolutionary Direction Set Hyperparameter Optimizer
|
|
16
|
+
|
|
17
|
+
It's a discrete optimizer, which means that it works with parameters that can
|
|
18
|
+
only take on a certain set of values. This works well for evaluating neural
|
|
19
|
+
networks and other large and complex models, since it takes so long to
|
|
20
|
+
train and test them, and since the hyperparameters can have non-intuitive,
|
|
21
|
+
strongly non-linear, and interactive effects.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
|
|
26
|
+
REDSHO (pictured in action above), an evolutionary search algorithm variant
|
|
27
|
+
inspired by direction set methods like
|
|
28
|
+
[Powell's method](https://en.wikipedia.org/wiki/Powell%27s_method), so much
|
|
29
|
+
so that it was originally called Evolutionary Powell's method .
|
|
30
|
+
Here is [a detailed description of how it works](https://brohrer.github.io/evopowell.html).
|
|
31
|
+
As far as I know this method is novel and has not previously been published.
|
|
32
|
+
Please let me know if you've seen something like it before.
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
Clone the repository to your local machine and install it from there.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
git clone https://codeberg.org/brohrer/redsho.git
|
|
40
|
+
python3 -m pip install -e redsho
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Run the demo
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
python3
|
|
47
|
+
```
|
|
48
|
+
```python3
|
|
49
|
+
>>> import redsho.demo
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Parallelization
|
|
53
|
+
|
|
54
|
+
REDSHO can seamlessly take advantage of multiple processor systems.
|
|
55
|
+
Instead of
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
import redsho.redsho
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
try
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import redsho.redsho_parallel
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
It automatically recuits all your processors but one to do its bidding.
|
redsho-0.1.0/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# redsho
|
|
2
|
+
|
|
3
|
+
Robust Evolutionary Direction Set Hyperparameter Optimizer
|
|
4
|
+
|
|
5
|
+
It's a discrete optimizer, which means that it works with parameters that can
|
|
6
|
+
only take on a certain set of values. This works well for evaluating neural
|
|
7
|
+
networks and other large and complex models, since it takes so long to
|
|
8
|
+
train and test them, and since the hyperparameters can have non-intuitive,
|
|
9
|
+
strongly non-linear, and interactive effects.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
REDSHO (pictured in action above), an evolutionary search algorithm variant
|
|
15
|
+
inspired by direction set methods like
|
|
16
|
+
[Powell's method](https://en.wikipedia.org/wiki/Powell%27s_method), so much
|
|
17
|
+
so that it was originally called Evolutionary Powell's method .
|
|
18
|
+
Here is [a detailed description of how it works](https://brohrer.github.io/evopowell.html).
|
|
19
|
+
As far as I know this method is novel and has not previously been published.
|
|
20
|
+
Please let me know if you've seen something like it before.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
Clone the repository to your local machine and install it from there.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://codeberg.org/brohrer/redsho.git
|
|
28
|
+
python3 -m pip install -e redsho
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Run the demo
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
python3
|
|
35
|
+
```
|
|
36
|
+
```python3
|
|
37
|
+
>>> import redsho.demo
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Parallelization
|
|
41
|
+
|
|
42
|
+
REDSHO can seamlessly take advantage of multiple processor systems.
|
|
43
|
+
Instead of
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
import redsho.redsho
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
try
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import redsho.redsho_parallel
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
It automatically recuits all your processors but one to do its bidding.
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "redsho"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "robust evolutionary direction set hyperparameter optimizer"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Brandon Rohrer", email = "brohrer@gmail.com" }
|
|
8
|
+
]
|
|
9
|
+
license = "MIT"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"matplotlib>=3.11.1",
|
|
13
|
+
"numpy>=2.5.2",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[build-system]
|
|
17
|
+
requires = ["hatchling"]
|
|
18
|
+
build-backend = "hatchling.build"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
[dependency-groups]
|
|
22
|
+
dev = [
|
|
23
|
+
"pytest>=9.1.1",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[tool.ruff]
|
|
27
|
+
line-length = 80
|
|
File without changes
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import matplotlib.pyplot as plt
|
|
2
|
+
import numpy as np
|
|
3
|
+
import toolbox as tb
|
|
4
|
+
from matplotlib import cm
|
|
5
|
+
|
|
6
|
+
from redsho.optimizer import Redsho
|
|
7
|
+
|
|
8
|
+
plt.switch_backend("agg")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def main():
|
|
12
|
+
# Define your conditions - your discrete search space - by creating
|
|
13
|
+
# a dictionary of key, value pairs
|
|
14
|
+
# where each key is a parameter name, and each value
|
|
15
|
+
# is the list of values that parameter can take.
|
|
16
|
+
# Those values can be any object: numbers or strings, lists or dicts,
|
|
17
|
+
# even functions of classes.
|
|
18
|
+
conditions = {
|
|
19
|
+
"x": list(np.linspace(0, np.pi, 10)),
|
|
20
|
+
"y": list(np.linspace(0, np.pi, 10)),
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
# Choose your optimization algorithm and run its optimize() method.
|
|
24
|
+
optimizer = Redsho(verbose=False)
|
|
25
|
+
_, _, results_logfile = optimizer.optimize(evaluate, conditions)
|
|
26
|
+
|
|
27
|
+
print(
|
|
28
|
+
"All done! The data on each condition evaluated, and its error\n"
|
|
29
|
+
+ f"are stored in {results_logfile}."
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# Optionally, when you're done you can turn the results into an image.
|
|
33
|
+
visualize(results_logfile)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def evaluate(x=0, y=0):
|
|
37
|
+
"""
|
|
38
|
+
The objective function is a 2D variant of the sinc function.
|
|
39
|
+
"""
|
|
40
|
+
x0 = 1
|
|
41
|
+
y0 = 1.5
|
|
42
|
+
return -np.sinc(x - x0) * np.sinc(y - y0)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def visualize(results_logfile):
|
|
46
|
+
"""
|
|
47
|
+
The error is multiplied by -1 here, so that it looks like the
|
|
48
|
+
algorithm is trying to climb the mountain, rather than find its
|
|
49
|
+
way to the bottom of a well. It's easier to visualize well and
|
|
50
|
+
a bit more cheerful.
|
|
51
|
+
"""
|
|
52
|
+
results = tb.results_csv_to_dict_list(results_logfile)
|
|
53
|
+
x = []
|
|
54
|
+
y = []
|
|
55
|
+
z = []
|
|
56
|
+
best_so_far = []
|
|
57
|
+
bsf = 1e-10
|
|
58
|
+
for result in results:
|
|
59
|
+
x.append(float(result["x"]))
|
|
60
|
+
y.append(float(result["y"]))
|
|
61
|
+
zval = -1 * float(result["error"])
|
|
62
|
+
z.append(zval)
|
|
63
|
+
bsf = max(bsf, zval)
|
|
64
|
+
best_so_far.append(bsf)
|
|
65
|
+
|
|
66
|
+
fig = plt.figure()
|
|
67
|
+
|
|
68
|
+
# The upper left plot shows a 3D surface of the objective function.
|
|
69
|
+
ax_surf = fig.add_subplot(221, projection="3d")
|
|
70
|
+
x_all_hi = np.linspace(0, np.pi, 100)
|
|
71
|
+
y_all_hi = np.linspace(0, np.pi, 100)
|
|
72
|
+
X, Y = np.meshgrid(x_all_hi, y_all_hi)
|
|
73
|
+
Z = -1 * evaluate(x=X, y=Y)
|
|
74
|
+
|
|
75
|
+
ax_surf.plot_surface(
|
|
76
|
+
X, Y, Z, cmap=cm.inferno, linewidth=0, antialiased=False
|
|
77
|
+
)
|
|
78
|
+
ax_surf.set_xlabel("x")
|
|
79
|
+
ax_surf.set_ylabel("y")
|
|
80
|
+
ax_surf.set_xlim(0, np.pi)
|
|
81
|
+
ax_surf.set_ylim(0, np.pi)
|
|
82
|
+
ax_surf.set_zlim(-0.2, 1)
|
|
83
|
+
|
|
84
|
+
# The upper right plot shows a 3D representation of the points
|
|
85
|
+
# in the search space that were evaluated.
|
|
86
|
+
ax_eval = fig.add_subplot(222, projection="3d")
|
|
87
|
+
ax_eval.scatter(
|
|
88
|
+
x,
|
|
89
|
+
y,
|
|
90
|
+
z,
|
|
91
|
+
c=z,
|
|
92
|
+
cmap=cm.inferno,
|
|
93
|
+
vmax=1,
|
|
94
|
+
vmin=-0.2,
|
|
95
|
+
s=10,
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
for i in range(len(x)):
|
|
99
|
+
ax_eval.plot(
|
|
100
|
+
[x[i], x[i]],
|
|
101
|
+
[y[i], y[i]],
|
|
102
|
+
[z[i], 0],
|
|
103
|
+
linewidth=0.5,
|
|
104
|
+
color="blue",
|
|
105
|
+
)
|
|
106
|
+
ax_eval.set_xlabel("x")
|
|
107
|
+
ax_eval.set_ylabel("y")
|
|
108
|
+
ax_eval.set_xlim(0, np.pi)
|
|
109
|
+
ax_eval.set_ylim(0, np.pi)
|
|
110
|
+
ax_eval.set_zlim(-0.2, 1)
|
|
111
|
+
|
|
112
|
+
# The lower left function shows the best error score found so far as
|
|
113
|
+
# more points are evaluated.
|
|
114
|
+
ax_bsf = fig.add_subplot(223)
|
|
115
|
+
ax_bsf.plot(
|
|
116
|
+
np.arange(len(best_so_far)) + 1,
|
|
117
|
+
best_so_far,
|
|
118
|
+
color="blue",
|
|
119
|
+
)
|
|
120
|
+
ax_bsf.set_xlabel("Points evaluated")
|
|
121
|
+
ax_bsf.set_ylabel("Best value so far")
|
|
122
|
+
ax_bsf.set_xlim(0, len(best_so_far) + 1)
|
|
123
|
+
ax_bsf.set_ylim(-0.01, 1.01)
|
|
124
|
+
|
|
125
|
+
# A 2D version of the plot in the upper right, showing the points
|
|
126
|
+
# evaluated so far and the error associated with them.
|
|
127
|
+
ax_cover = fig.add_subplot(224)
|
|
128
|
+
ax_cover.scatter(
|
|
129
|
+
x,
|
|
130
|
+
y,
|
|
131
|
+
c=z,
|
|
132
|
+
vmax=1,
|
|
133
|
+
vmin=-0.2,
|
|
134
|
+
cmap=cm.inferno,
|
|
135
|
+
s=20,
|
|
136
|
+
)
|
|
137
|
+
ax_cover.set_xlabel("x")
|
|
138
|
+
ax_cover.set_ylabel("y")
|
|
139
|
+
ax_cover.set_xlim(-0.1, np.pi + 0.1)
|
|
140
|
+
ax_cover.set_ylim(-0.1, np.pi + 0.1)
|
|
141
|
+
|
|
142
|
+
viz_file = "demo_visualization.png"
|
|
143
|
+
fig.savefig(viz_file, dpi=300)
|
|
144
|
+
plt.close()
|
|
145
|
+
|
|
146
|
+
print(f"There's also a 3D visualization of it in {viz_file}.")
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
main()
|