Skip to content

Commit ca4ffba

Browse files
renesassCarolin Benjaminsdengdifaneddiebergmantimruhkopf
authored
Version 2.0.0a1 (#875)
## Big Changes * We redesigned the scenario class completely. The scenario is implemented as a dataclass now and holds only environment variables (like limitations or save directory). Everything else was moved to the components directly. * We removed runtime optimization completely (no adaptive capping or imputing anymore). * We removed the command-line interface and restructured everything alongside. Since SMAC was building upon the command-line interface (especially in combination with the scenario), it was complicated to understand the behavior or find specific implementations. With the removal, we re-wrote everything in python and re-implemented the feature of using scripts as target functions. * Introducing trials: Each config/seed/budget/instance calculation is a trial. * The configuration chooser is integrated into the SMBO object now. Therefore, SMBO finally implements an ask-tell interface now. * Facades are redesigned so that they accept instantiated components directly. If a component is not passed, a default component is used, which is specified for each facade individually in the form of static methods. You can use those static methods directly to adapt a component to your choice. * A lot of API changes and renamings (e.g., RandomConfigurationChooser -> RandomDesign, Runhistory2EPM -> RunHistoryEncoder). * Ambiguous variables are renamed and unified across files. * Dependencies of modules are reduced drastically. * We incorporated Pynisher 1.0, which ensures limitations cross-platform. * We incorporated ConfigSpace 0.6, which simplified our examples. * Examples and documentation are completely reworked. Examples use the new ConfigSpace, and the documentation is adapted to version 2.0. * Transparent target function signatures: SMAC checks now explicitly if an argument is available (the required arguments are now specified in the intensifier). If there are more arguments that are not passed by SMAC, a warning is raised. * Components implement a ``meta`` property now, all of which describe the initial state of SMAC. The facade collects all metadata and saves the initial state of the scenario. * Improved multi-objective in general: RunHistory (in addition to RunHistoryEncoder) both incorporates the multi-objective algorithm. In other words, if the multi-objective algorithm changes the output, it directly affects the optimization process. * Configspace is saved in json only * StatusType is saved as integer and not as dict anymore * We changed the behavior of continuing a run: * SMAC automatically checks if a scenario was saved earlier. If there exists a scenario and the initial state is the same, SMAC automatically loads the previous data. However, continuing from that run is not possible yet. * If there was a scenario earlier, but the initial state is different, then the user is asked to overwrite the run or to still continue the run although the state is different (Note that this only can happen if the name specified in the scenario is the same). Alternatively, an `old` to the old run is added (e.g., the name was test, it becomes test-old). * The initial state of the SMAC run also specifies the name (if no name in the scenario is specified). If the user changes something in the code base or in the scenario, the name and, therefore, the save location automatically changes. ## New Features * Added a new termination feature: Use `terminate_cost_threshold` in the scenario to stop the optimization after a configuration was evaluated with a cost lower than the threshold. * Callbacks are completely redesigned. Added callbacks to the facade are called in different positions in the Bayesian optimization loop. * The multi-objective algorithm `MeanAggregationStrategy` supports objective weights now. * RunHistory got more methods like ``get_incumbent`` or ``get_pareto_front``. ## Fixes * You ever noticed that the third configuration has no origin? It's fixed now. * We fixed ParEGO (it updates every time training is performed now). ## Optimization Changes * Changed initial design behavior * You can add additional configurations now. * ``max_ratio`` will limit both ``n_configs`` and ``n_configs_per_hyperparameter`` but not additional configurations * Reduced default ``max_ratio`` to 0.1. ## Code Related * Converted all unittests to pytests. * Instances, seeds, and budgets can be set to none now. However, mixing none and non-none will throw an exception. Co-authored-by: Carolin Benjamins <[email protected]> Co-authored-by: dengdifan <[email protected]> Co-authored-by: eddiebergman <[email protected]> Co-authored-by: timruhkopf <[email protected]> Co-authored-by: Katharina Eggensperger <[email protected]>
1 parent 83a9bbe commit ca4ffba

File tree

496 files changed

+30199
-136293
lines changed

Some content is hidden

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

496 files changed

+30199
-136293
lines changed

.github/workflows/dist.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ on:
99
branches:
1010
- main
1111
- development
12+
- development-2.0
1213

1314
# Trigger on a open/push to a PR targeting one of these branches
1415
pull_request:
1516
branches:
1617
- main
1718
- development
19+
- development-2.0
1820

1921
jobs:
2022
dist:
@@ -27,7 +29,7 @@ jobs:
2729
- name: Setup Python
2830
uses: actions/setup-python@v4
2931
with:
30-
python-version: "3.9"
32+
python-version: "3.10"
3133

3234
- name: Build dist
3335
run: |

.github/workflows/docs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ on:
1111
branches:
1212
- main
1313
- development
14+
- development-2.0
1415

1516
# Trigger on a open/push to a PR targeting one of these branches
1617
pull_request:
1718
branches:
1819
- main
1920
- development
21+
- development-2.0
2022

2123
env:
2224
name: SMAC3
@@ -31,7 +33,7 @@ jobs:
3133
- name: Setup Python
3234
uses: actions/setup-python@v4
3335
with:
34-
python-version: "3.9"
36+
python-version: "3.10"
3537

3638
- name: Install dependencies
3739
run: |

.github/workflows/examples.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.

.github/workflows/pre-commit.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ on:
99
branches:
1010
- main
1111
- development
12+
- development-2.0
1213

1314
# When a push occurs on a PR that targets these branches
1415
pull_request:
1516
branches:
1617
- main
1718
- development
19+
- development-2.0
1820

1921
jobs:
2022
run-all-files:

.github/workflows/pytest.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ on:
99
branches:
1010
- main
1111
- development
12+
- development-2.0
1213

1314
# Triggers with push to a pr aimed at main
1415
pull_request:
1516
branches:
1617
- main
1718
- development
19+
- development-2.0
1820

1921
schedule:
2022
# Every day at 7AM UTC
@@ -43,7 +45,8 @@ jobs:
4345
strategy:
4446
fail-fast: false
4547
matrix:
46-
python-version: ["3.9"]
48+
python-version: ["3.8", "3.9", "3.10"]
49+
# python-version: ["3.8"]
4750
os: ["ubuntu-latest"]
4851

4952
steps:
@@ -96,7 +99,8 @@ jobs:
9699
strategy:
97100
fail-fast: false
98101
matrix:
99-
python-version: ["3.7", "3.8", "3.9", "3.10"]
102+
python-version: ["3.8", "3.9", "3.10"]
103+
# python-version: ["3.8"]
100104
os: ["ubuntu-latest"]
101105

102106
steps:
@@ -132,7 +136,8 @@ jobs:
132136
strategy:
133137
fail-fast: false
134138
matrix:
135-
python-version: ["3.7", "3.8", "3.9", "3.10"]
139+
python-version: ["3.8", "3.9", "3.10"]
140+
# python-version: ["3.8"]
136141
os: ["ubuntu-latest"]
137142

138143
steps:

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,13 @@ dmypy.json
134134
.pyre/
135135

136136
*smac3-output_*
137+
*smac3_output*
137138

138139
# macOS files
139140
.DS_Store
140141

141142
# Remove docker files
142-
docker
143+
docker
144+
145+
# Others
146+
src

MANIFEST.in

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
# MANIFEST.in defines what files are included/excluded from a built pacakage
2-
# that gets installed through PyPI or through `pip install`
3-
# To modify, check out
4-
# https://packaging.python.org/en/latest/guides/using-manifest-in/
5-
6-
# Include individual files
71
include LICENSE.txt
8-
include requirements.txt
92
include smac/py.typed # This file is to export types
3+
include smac/logging.yml
104

115
prune tests
126
prune examples

README.md

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,39 @@
77
[![codecov
88
Status](https://codecov.io/gh/automl/SMAC3/branch/master/graph/badge.svg)](https://codecov.io/gh/automl/SMAC3)
99

10-
SMAC is a tool for algorithm configuration to optimize the parameters of
11-
arbitrary algorithms, including hyperparameter optimization of Machine Learning algorithms. The main core consists of
12-
Bayesian Optimization in combination with an aggressive racing mechanism to
13-
efficiently decide which of two configurations performs better.
10+
SMAC is a tool for algorithm configuration to optimize the parameters of arbitrary algorithms, including hyperparameter
11+
optimization of Machine Learning algorithms. The main core consists of Bayesian Optimization in combination with an
12+
aggressive racing mechanism to efficiently decide which of two configurations performs better.
1413

15-
SMAC3 is written in Python3 and continuously tested with Python 3.7, 3.8, 3.9, and 3.10. Its Random
14+
SMAC3 is written in Python3 and continuously tested with Python 3.8, 3.9, and 3.10. Its Random
1615
Forest is written in C++. In further texts, SMAC is representatively mentioned for SMAC3.
1716

1817
> [Documention](https://automl.github.io/SMAC3)
1918
2019
> [Roadmap](https://github.com/orgs/automl/projects/5/views/2)
2120
2221

22+
## Important: Changes in v2.0
23+
24+
With the next big major release of SMAC, we drastically boosted the user experience by improving the APIs and how the
25+
pipelining is done (see [changelog](CHANGELOG.md)). However, cleaning the code base, we removed the command-line
26+
interface (calling a target function from a script is still supported), runtime optimization, and pSMAC. Also,
27+
python 3.7 is not supported anymore. If you depend on those functionalities, we kindly ask you to keep using v1.4.
28+
29+
We are excited to introduce the new major release and look forward to developing new features on the new code base.
30+
We hope you enjoy this new user experience as much as we do. 🚀
31+
32+
2333
## Installation
2434

25-
Create a new environment with python 3.9 and make sure swig is installed either on your system or
35+
This instruction is for the installation on a Linux system, for Windows and Mac and further information see the [documention](https://automl.github.io/SMAC3/main/installation.html).
36+
37+
Create a new environment with python 3.10 and make sure swig is installed either on your system or
2638
inside the environment. We demonstrate the installation via anaconda in the following:
2739

2840
Create and activate environment:
2941
```
30-
conda create -n SMAC python=3.9
42+
conda create -n SMAC python=3.10
3143
conda activate SMAC
3244
```
3345

@@ -44,56 +56,41 @@ pip install smac
4456
Or alternatively, clone the environment:
4557
```
4658
git clone https://github.com/automl/SMAC3.git && cd SMAC3
47-
pip install -r requirements.txt
48-
pip install .
59+
pip install -e .[dev]
4960
```
5061

51-
We refer to the [documention](https://automl.github.io/SMAC3) for further installation options.
52-
5362

5463
## Minimal Example
5564

5665
```py
57-
import numpy as np
58-
59-
from sklearn.ensemble import RandomForestClassifier
60-
from ConfigSpace import ConfigurationSpace
61-
from ConfigSpace.hyperparameters import UniformIntegerHyperparameter
62-
from smac.facade.smac_bb_facade import SMAC4BB
63-
from smac.scenario.scenario import Scenario
64-
65-
66-
X_train, y_train = np.random.randint(2, size=(20, 2)), np.random.randint(2, size=20)
67-
X_val, y_val = np.random.randint(2, size=(5, 2)), np.random.randint(2, size=5)
66+
from ConfigSpace import Configuration, ConfigurationSpace
6867

68+
import numpy as np
69+
from smac import HyperparameterOptimizationFacade, Scenario
70+
from sklearn import datasets
71+
from sklearn.svm import SVC
72+
from sklearn.model_selection import cross_val_score
6973

70-
def train_random_forest(config):
71-
model = RandomForestClassifier(max_depth=config["depth"])
72-
model.fit(X_train, y_train)
74+
iris = datasets.load_iris()
7375

74-
# Define the evaluation metric as return
75-
return 1 - model.score(X_val, y_val)
7676

77+
def train(config: Configuration, seed: int = 0) -> float:
78+
classifier = SVC(C=config["C"], random_state=seed)
79+
scores = cross_val_score(classifier, iris.data, iris.target, cv=5)
80+
return 1 - np.mean(scores)
7781

78-
if __name__ == "__main__":
79-
# Define your hyperparameters
80-
configspace = ConfigurationSpace()
81-
configspace.add_hyperparameter(UniformIntegerHyperparameter("depth", 2, 100))
8282

83-
# Provide meta data for the optimization
84-
scenario = Scenario({
85-
"run_obj": "quality", # Optimize quality (alternatively runtime)
86-
"runcount-limit": 10, # Max number of function evaluations (the more the better)
87-
"cs": configspace,
88-
})
83+
configspace = ConfigurationSpace({"C": (0.100, 1000.0)})
8984

90-
smac = SMAC4BB(scenario=scenario, tae_runner=train_random_forest)
91-
best_found_config = smac.optimize()
85+
# Scenario object specifying the optimization environment
86+
scenario = Scenario(configspace, deterministic=True, n_trials=200)
9287

88+
# Use SMAC to find the best configuration/hyperparameters
89+
smac = HyperparameterOptimizationFacade(scenario, train)
90+
incumbent = smac.optimize()
9391
```
9492

95-
More examples can be found in the [documention](https://automl.github.io/SMAC3).
96-
93+
More examples can be found in the [documention](https://automl.github.io/SMAC3/main/examples/).
9794

9895

9996
## License
@@ -109,15 +106,18 @@ You should have received a copy of the 3-clause BSD license
109106
along with this program (see LICENSE file).
110107
If not, see [here](https://opensource.org/licenses/BSD-3-Clause).
111108

109+
112110
## Miscellaneous
113111

114112
SMAC3 is developed by the [AutoML Groups of the Universities of Hannover and
115113
Freiburg](http://www.automl.org/).
116114

117-
If you have found a bug, please report to [issues](https://github.com/automl/SMAC3/issues). Moreover, we are appreciating any kind of help.
118-
Find our guidlines for contributing to this package [here](https://github.com/automl/SMAC3/blob/master/.github/CONTRIBUTING.md).
115+
If you have found a bug, please report to [issues](https://github.com/automl/SMAC3/issues). Moreover, we are
116+
appreciating any kind of help. Find our guidlines for contributing to this package
117+
[here](https://github.com/automl/SMAC3/blob/master/.github/CONTRIBUTING.md).
119118

120-
If you use SMAC in one of your research projects, please cite our [JMLR paper](https://jmlr.org/papers/v23/21-0888.html):
119+
If you use SMAC in one of your research projects, please cite our
120+
[JMLR paper](https://jmlr.org/papers/v23/21-0888.html):
121121
```
122122
@article{JMLR:v23:21-0888,
123123
author = {Marius Lindauer and Katharina Eggensperger and Matthias Feurer and André Biedenkapp and Difan Deng and Carolin Benjamins and Tim Ruhkopf and René Sass and Frank Hutter},
@@ -131,4 +131,4 @@ If you use SMAC in one of your research projects, please cite our [JMLR paper](h
131131
}
132132
```
133133

134-
Copyright (C) 2016-2022 [AutoML Group](http://www.automl.org/).
134+
Copyright (C) 2016-2022 [AutoML Group](http://www.automl.org).

0 commit comments

Comments
 (0)