Skip to content

Commit c9f792f

Browse files
authored
Merge pull request #255 from automl/development
Development v 1.2.0
2 parents dc2f917 + e731216 commit c9f792f

141 files changed

Lines changed: 3079 additions & 4739 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,12 @@
33
data/
44
output/
55
results/
6-
vespy/
76
_run_number.txt
8-
logo.py
9-
traj2csv.py
10-
rh2csv.py
117

128
# Specific examples
139
data/
1410
data_original/
1511
results/
16-
examples/spear_qcp_large/
17-
examples/spear_qcp_small/example_output_1/validated_rh.json
18-
examples/spear_qcp_small/example_output_2/validated_rh.json
19-
examples/spear_qcp_small/example_output_3/validated_rh.json
2012

2113
# Old versions
2214
*.old
@@ -96,6 +88,7 @@ target/
9688

9789
# pyenv
9890
.python-version
91+
.idea
9992

10093
# celery beat schedule file
10194
celerybeat-schedule

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
include requirements.txt
22
recursive-include cave/html/web_files *.css *.js *.png *.json *.svg *.eot *.ttf *.woff*
33
include cave/plot/mpl_style
4+
include cave/utils/options/*.ini

README.md

Lines changed: 52 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,32 @@ Status for master branch / development branch:
22

33
[![Build Status](https://travis-ci.org/automl/CAVE.svg?branch=master)](https://travis-ci.org/automl/CAVE) / [![Build Status](https://travis-ci.org/automl/CAVE.svg?branch=development)](https://travis-ci.org/automl/CAVE)
44

5-
# CAVE
5+
# CAVE
66
CAVE is a versatile analysis tool for automatic algorithm configurators. It generates comprehensive reports (e.g. http://ml.informatik.uni-freiburg.de/~biedenka/cave.html) that
77
give you insights into the configured algorithm, the used instance set and also the configuration tool itself.
8-
The current version works out-of-the-box with [SMAC3](https://github.com/automl/SMAC3), but can be easily adapted to other configurators, as long as they use the same output-structure.
8+
The current version works out-of-the-box with [BOHB](https://github.com/automl/HpBandSter) and [SMAC3](https://github.com/automl/SMAC3), but can be easily adapted to other configurators, either by adding a custom reader or by [using the CSV-Reader](https://automl.github.io/CAVE/stable/manualdoc/fileformats.html#csv) integrated in CAVE.
99
You can also find a [talk on CAVE](https://drive.google.com/file/d/1lNu6sZGB3lcr6fYI1tzLOJzILISO9WE1/view) online.
1010

11-
# LICENSE
12-
Please refer to [LICENSE](https://github.com/automl/CAVE/blob/master/LICENSE)
13-
14-
If you use out tool, please cite us:
15-
16-
```bibtex
17-
@InProceedings{biedenkapp-lion18a,
18-
author = {A. Biedenkapp and J. Marben and M. Lindauer and F. Hutter},
19-
title = {{CAVE}: Configuration Assessment, Visualization and Evaluation},
20-
booktitle = {Proceedings of the International Conference on Learning and Intelligent Optimization (LION'18)},
21-
year = {2018}}
22-
23-
@journal{
24-
title = {BOAH: A Tool Suite for Multi-Fidelity Bayesian Optimization & Analysis of Hyperparameters},
25-
author = {M. Lindauer and K. Eggensperger and M. Feurer and A. Biedenkapp and J. Marben and P. Müller and F. Hutter},
26-
journal = {arXiv:1908.06756 {[cs.LG]}},
27-
date = {2019},
28-
}
29-
```
30-
11+
If you use this tool, please [cite us](#license).
3112

13+
If you have feature requests or encounter bugs, feel free to contact us via the issue-tracker.
3214

3315
# OVERVIEW
3416
CAVE is an analysis tool.
35-
It is written in Python 3.5 and uses [SMAC3](https://github.com/automl/SMAC3), [pimp](https://github.com/automl/ParameterImportance) and [ConfigSpace](https://github.com/automl/ConfigSpace).
36-
CAVE generates performance-values (e.g. PAR10), scatter- and cdf-plots to compare the default and the optimized incumbent and provides further inside into the optimization process by quantifying the parameter- and feature-importance.
17+
It is written in Python 3.5 and uses [SMAC3](https://github.com/automl/SMAC3), [pimp](https://github.com/automl/ParameterImportance), and [ConfigSpace](https://github.com/automl/ConfigSpace).
18+
CAVE generates performance-values (e.g. PAR10), scatter- and cdf-plots to compare the default and the optimized incumbent and provides further inside into the optimization process by quantifying the parameter- and feature-importance.
19+
CAVE also generates configurator footprints to get a grip on the search behaviour of the configurator and many budget-based analyses.
20+
CAVE integrates seamlessly with [jupyter-notebooks](https://automl.github.io/CAVE/stable/manualdoc/jupyternotebook.html).
3721

3822
# REQUIREMENTS
3923
- Python 3.5
4024
- SMAC3 and all its dependencies
4125
- ParameterImportance and all its dependencies
26+
- HpBandSter and all its dependencies
4227
- everything specified in requirements.txt
43-
Some of the plots in the report are generated using [bokeh](https://bokeh.pydata.org/en/latest/). To automagically export them as `.png`s, you need to also install [phantomjs-prebuilt](https://www.npmjs.com/package/phantomjs-prebuilt). CAVE will run without it, but you will need to manually export the plots if you wish to use them.
44-
- phatomjs-prebuilt
28+
29+
Some of the plots in the report are generated using [bokeh](https://bokeh.pydata.org/en/latest/). To automagically export them as `.png`s, you need to also install [phantomjs-prebuilt](https://www.npmjs.com/package/phantomjs-prebuilt). CAVE will run without it, but you will need to manually export the plots if you wish to use them (which is easily done through a button in the report).
30+
4531

4632
# INSTALLATION
4733
You can install CAVE from pip:
@@ -59,16 +45,19 @@ npm install phantomjs-prebuilt
5945
```
6046

6147
# USAGE
62-
We are currently working on the [documentation](https://automl.github.io/CAVE/stable/) of CAVE. Here a little Quickstart-Guide.
48+
Have a look into the [documentation](https://automl.github.io/CAVE/stable/) of CAVE. Here a little Quickstart-Guide.
6349

64-
You can analyze multiple folders (that are generated with the same scenario) for the analysis, simply provide the paths to all the individual results in `--folders`.
50+
You can analyze results of an optimizer in one or multiple folders (that are generated with the same scenario, i.e. parallel runs).
51+
Provide paths to all the individual parallel results using `--folders`.
6552

66-
Commandline arguments:
53+
Some helpful commandline arguments:
6754
- `--folders`: path(s) to folder(s) containing the configurator-output (works with `output/run_*`)
6855

56+
**NOTE:** *the keyword `--folders` is optional, CAVE interprets positional arguments in the commandline as folders of parallel runs*
57+
6958
Optional:
7059
- `--output`: where to save the CAVE-output
71-
- `--file_format`: of results to be analyzed, choose from [SMAC3](https://github.com/automl/SMAC3), [SMAC2](https://www.cs.ubc.ca/labs/beta/Projects/SMAC), [CSV](https://automl.github.io/CAVE/stable/quickstart.html#csv) or [BOHB](https://github.com/automl/HpBandSter)
60+
- `--file_format`: if the automatic file-detection fails for some reason, choose from [SMAC3](https://github.com/automl/SMAC3), [SMAC2](https://www.cs.ubc.ca/labs/beta/Projects/SMAC), [CSV](https://automl.github.io/CAVE/stable/quickstart.html#csv) or [BOHB](https://github.com/automl/HpBandSter)
7261
- `--validation_format`: of (optional) validation data (to enhance epm-quality where appropriate), choose from [SMAC3](https://github.com/automl/SMAC3), [SMAC2](https://www.cs.ubc.ca/labs/beta/Projects/SMAC), [CSV](https://automl.github.io/CAVE/stable/quickstart.html#csv) or NONE
7362
- `--ta_exec_dir`: target algorithm execution directories, this should be one or multiple path(s) to
7463
the directories from which the configurator was run initially. not necessary for all configurators (BOHB doesn't need it). used to find instance-files and
@@ -79,7 +68,7 @@ Optional:
7968
- `--feature_analysis`: analysis features is expensive, so you can specify which
8069
algorithm to run: `box_violin`, `clustering`, `importance` and/or `feature_cdf`.
8170
either provide a combination of those or use `all` or `none`
82-
- `--no_tabular_analysis`: toggles the tabular analysis
71+
- `--no_performance_table`: toggles the tabular analysis
8372
- `--no_ecdf`, `--no_scatter_plots`: toggle ecdf- and scatter-plots
8473
- `--no_cost_over_time`: toggles the cost-over-time plot
8574
- `--no_parallel_coordinates`: toggles the parallel-coordinates plot
@@ -90,32 +79,50 @@ Optional:
9079
- `--cot_inc_traj`: how the incumbent trajectory for the cost-over-time plot will be generated if the optimizer is BOHB (from [`racing`, `minimum`, `prefer_higher_budget`])
9180

9281
For further information on to use CAVE, see:
93-
`python scripts/cave.py -h
82+
`cave -h`
9483

9584
# EXAMPLE
85+
## SMAC3
9686
You can run the spear-qcp example like this:
9787
```
98-
cave --folders examples/smac3/example_output/* --ta_exec examples/smac3/ --output CAVE_results/
88+
cave examples/smac3/example_output/* --ta_exec examples/smac3/ --output output/smac3_example
9989
```
10090
This will analyze the results located in `examples/smac3` in the dirs `example_output/run_1` and `example_output/run_2`.
10191
The report is located in `CAVE_results/report.html`.
10292
`--ta_exec` corresponds to the folder from which the optimizer was originally executed (used to find the necessary files for loading the `scenario`).
10393
For other formats, e.g.:
10494
```
105-
cave --folders examples/smac2/ --ta_exec_dir examples/smac2/smac-output/aclib/state-run1/ --file_format smac2 --no_algorithm_footprint
106-
cave --folders examples/csv_allinone/ --ta_exec_dir examples/csv_allinone/ --file_format csv
107-
95+
cave examples/smac2/ --ta_exec_dir examples/smac2/smac-output/aclib/state-run1/ --output output/smac2_example
96+
cave examples/csv_allinone/ --ta_exec_dir examples/csv_allinone/ --output output/csv_example
10897
```
10998

110-
# USAGE WITH BOHB
111-
You can also use cave with Configurators that use budgets to estimate a quality of a certain algorithm (e.g. epochs in
112-
neural networks), a good example for this behaviour is [BOHB](https://github.com/automl/HpBandSter). To interpret BOHB's
113-
results, you need to install an additional dependency:
114-
```
115-
pip install hpbandster
99+
## BOHB
100+
You can also use cave with configurators that use budgets to estimate a quality of a certain algorithm (e.g. epochs in
101+
neural networks), a good example for this behaviour is [BOHB](https://github.com/automl/HpBandSter).
116102
```
117-
and then you can use CAVE as usual, specifying the file_format as BOHB:
118-
```
119-
cave --folders examples/bohb --file_format BOHB --output CAVE_BOHB_results
103+
cave examples/bohb --output output/bohb_example
120104
```
105+
121106
There is an [example jupyter-notebook](https://github.com/automl/HpBandSter/blob/add_docu/hpbandster/examples/Workflow.ipynb) on how to use CAVE with BOHB.
107+
# LICENSE
108+
Please refer to [LICENSE](https://github.com/automl/CAVE/blob/master/LICENSE)
109+
110+
If you use out tool, please cite us:
111+
112+
```bibtex
113+
@InProceedings{biedenkapp-lion18a,
114+
author = {A. Biedenkapp and J. Marben and M. Lindauer and F. Hutter},
115+
title = {{CAVE}: Configuration Assessment, Visualization and Evaluation},
116+
booktitle = {Proceedings of the International Conference on Learning and Intelligent Optimization (LION'18)},
117+
year = {2018}}
118+
119+
@journal{
120+
title = {BOAH: A Tool Suite for Multi-Fidelity Bayesian Optimization & Analysis of Hyperparameters},
121+
author = {M. Lindauer and K. Eggensperger and M. Feurer and A. Biedenkapp and J. Marben and P. Müller and F. Hutter},
122+
journal = {arXiv:1908.06756 {[cs.LG]}},
123+
date = {2019},
124+
}
125+
```
126+
127+
128+

cave/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.1.8"
1+
__version__ = "1.2.0"

cave/analyzer/algorithm_footprint.py

Lines changed: 68 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,75 @@
11
import os
2-
from collections import OrderedDict
3-
import logging
42

5-
from bokeh.plotting import show
6-
from bokeh.io import output_notebook
73
from bokeh.embed import components
4+
from bokeh.io import output_notebook
5+
from bokeh.plotting import show
86

97
from cave.analyzer.base_analyzer import BaseAnalyzer
108
from cave.plot.algorithm_footprint import AlgorithmFootprintPlotter
9+
from cave.utils.helpers import NotApplicable
1110
from cave.utils.timing import timing
1211

12+
1313
class AlgorithmFootprint(BaseAnalyzer):
14+
"""
15+
The instance features are projected into a two/three dimensional space using principal component analysis (PCA)
16+
and the footprint of each algorithm is plotted, i.e., on which instances the default or the optimized
17+
configuration performs well. In contrast to the other analysis methods in this section, these plots allow
18+
insights into which of the two configurations performs well on specific types or clusters of instances. Inspired
19+
by Smith-Miles.
20+
"""
1421

1522
@timing
16-
def __init__(self, algorithms, epm_rh, train, test, features,
17-
cutoff, output_dir, rng, density=200, purity=0.95):
18-
self.logger = logging.getLogger(self.__module__ + '.' + self.__class__.__name__)
23+
def __init__(self,
24+
runscontainer,
25+
density=200,
26+
purity=0.95):
27+
"""
28+
Parameters
29+
----------
30+
runscontainer: RunsContainer
31+
contains all important information about the configurator runs
32+
"""
33+
super().__init__(runscontainer)
34+
35+
# Aggregated run over current runscontainer
36+
self.logger.info("Note: Algorithm Footprint does not support budgets / fidelities yet.")
37+
agg_run = self.runscontainer.get_aggregated(False, False)[0]
38+
39+
algorithms = [(agg_run.default, "default"),
40+
(agg_run.incumbent, "incumbent")]
41+
epm_rh = agg_run.epm_runhistory
42+
train = agg_run.scenario.train_insts
43+
test = agg_run.scenario.test_insts
44+
features = agg_run.scenario.feature_dict
45+
cutoff = agg_run.scenario.cutoff
46+
output_dir = agg_run.output_dir
47+
rng = agg_run.rng
1948

2049
# filter instance features
50+
self.logger.debug("Features: " + str(features))
2151
train_feats = {k: v for k, v in features.items() if k in train}
2252
test_feats = {k: v for k, v in features.items() if k in test}
2353
if not (train_feats or test_feats):
2454
self.logger.warning("No instance-features could be detected. "
2555
"No algorithm footprints available.")
26-
raise ValueError("Could not detect any instances.")
56+
raise NotApplicable("Could not detect any instances.")
2757

2858
self.logger.info("... algorithm footprints for: {}".format(",".join([a[1] for a in algorithms])))
29-
self.footprint = AlgorithmFootprintPlotter(epm_rh,
30-
train_feats, test_feats,
31-
algorithms,
32-
cutoff,
33-
output_dir,
34-
rng=rng)
59+
60+
try:
61+
self.footprint = AlgorithmFootprintPlotter(epm_rh,
62+
train_feats, test_feats,
63+
algorithms,
64+
cutoff,
65+
output_dir,
66+
rng=rng)
67+
except ValueError as err:
68+
self.logger.debug(err, exc_info=1)
69+
self.error = str(err)
70+
71+
def get_name(self):
72+
return "Algorithm Footprint"
3573

3674
def _plot(self):
3775
# Plot footprints
@@ -45,18 +83,22 @@ def get_jupyter(self):
4583
show(bokeh_plot)
4684

4785
def get_html(self, d=None, tooltip=None):
48-
script, div = components(self._plot())
49-
bokeh_components = script, div
50-
if d is not None:
51-
d["tooltip"] = tooltip
52-
# Interactive bokeh-plot
53-
d["Interactive Algorithm Footprint"] = {"bokeh" : (script, div)}
54-
for plots in self.plots3d:
55-
header = os.path.splitext(os.path.split(plots[0])[1])[0][10:-2]
56-
header = header[0].upper() + header[1:].replace('_', ' ')
57-
d[header] = {"figure_x2": plots}
58-
59-
return bokeh_components
86+
87+
if self.error:
88+
if d is not None:
89+
d["Algorithm Footprint"] = {"else": self.error}
90+
return self.error
91+
else:
92+
bokeh_components = components(self._plot())
93+
if d is not None:
94+
d["Algorithm Footprint"] = {"tooltip" : self.__doc__}
95+
# Interactive bokeh-plot
96+
d["Algorithm Footprint"]["Interactive Algorithm Footprint"] = {"bokeh" : bokeh_components}
97+
for plots in self.plots3d:
98+
header = os.path.splitext(os.path.split(plots[0])[1])[0][10:-2]
99+
header = header[0].upper() + header[1:].replace('_', ' ')
100+
d["Algorithm Footprint"][header] = {"figure_x2": plots}
101+
return bokeh_components
60102

61103
def get_plots(self):
62104
all_plots = []

0 commit comments

Comments
 (0)