Skip to content

Commit

Permalink
Merge branch 'development' into v2.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamc committed Jan 21, 2025
2 parents d0d988c + 3c36ce0 commit d2cbb7b
Show file tree
Hide file tree
Showing 134 changed files with 546 additions and 289 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
- Correct intensifier for Algorithm Configuration Facade (#1162, #1165)
- Migrate sphinx docs to mkdocs (#1155)

# 2.2.1
## Bugfixes
- Fix bug in differential evolution acquisition maximizer in case the search space contains categorical hyperparameters (#1150)
- Fix wrong attr query in the target function runner (crash cost) (#1176)
- Fix kwargs for DifferentialEvolution (#1187)
- Fix PiBo implementation (#1076)
- Add fix for local search running forever (#1194)

## Improvements
- Add logger information on handling of stopIteration error (#960)
- Replace deprecated ConfigSpace methods (#1139)
- Separated Wallclock time measurements from CPU time measurements and storing them under new 'cpu_time' variable (#1173)
- Adapt RunHistory to be human readable (# 1174)

## Dependencies
- Allow numpy >= 2.x (#1146)
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ date-released: "2016-08-17"
url: "https://automl.github.io/SMAC3/master/index.html"
repository-code: "https://github.com/automl/SMAC3"

version: "2.2.0"
version: "2.3.0"

type: "software"
keywords:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ SMAC License

BSD 3-Clause License

Copyright (c) 2016-2018, Ml4AAD Group (http://www.ml4aad.org/)
Copyright (c) 2025, Leibniz University Hannover - Institute of AI (https://www.ai.uni-hannover.de/)
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SHELL := /bin/bash

NAME := SMAC3
PACKAGE_NAME := smac
VERSION := 2.2.0
VERSION := 2.3.0

DIR := "${CURDIR}"
SOURCE_DIR := ${PACKAGE_NAME}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SMAC offers a robust and flexible framework for Bayesian Optimization to support
hyperparameter configurations for their (Machine Learning) algorithms, datasets and applications at hand. The main core
consists of Bayesian Optimization in combination with an aggressive racing mechanism to efficiently decide which of two configurations performs better.

SMAC3 is written in Python3 and continuously tested with Python 3.8, 3.9, and 3.10. Its Random
SMAC3 is written in Python3 and continuously tested with Python 3.8, 3.9, and 3.10 (and works with newer python versions). Its Random
Forest is written in C++. In further texts, SMAC is representatively mentioned for SMAC3.

> [Documentation](automl.github.io/SMAC3/latest/)
Expand Down Expand Up @@ -144,4 +144,4 @@ If you use SMAC in one of your research projects, please cite our
}
```

Copyright (C) 2016-2022 [AutoML Group](http://www.automl.org).
Copyright (c) 2025, [Leibniz University Hannover - Institute of AI](https://www.ai.uni-hannover.de/)
1 change: 0 additions & 1 deletion docs/1_installation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Installation

## Requirements

SMAC is written in python3 and therefore requires an environment with python>=3.8.
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced_usage/10_continue.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ The behavior can be controlled by setting the parameter ``overwrite`` in the fac
and the old run is not affected.


Please have a look at our [continue example](../examples/1%20Basics/5_continue.html).
Please have a look at our [continue example](../examples/1%20Basics/5_continue.md).
6 changes: 6 additions & 0 deletions docs/advanced_usage/2_multi_fidelity.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,11 @@ target function but ``min_budget`` and ``max_budget`` are used internally to det
each stage. That's also the reason why ``min_budget`` and ``max_budget`` are *not required* when using instances:
The ``max_budget`` is simply the max number of instances, whereas the ``min_budget`` is simply 1.

!!! warning
``smac.main.config_selector.ConfigSelector`` contains the ``min_trials`` parameter. This parameter determines
how many samples are required to train the surrogate model. If budgets are involved, the highest budgets
are checked first. For example, if min_trials is three, but we find only two trials in the runhistory for
the highest budget, we will use trials of a lower budget instead.

Please have a look into our [multi-fidelity examples](Multi-Fidelity and Multi-Instances) to see how to use
multi-fidelity optimization in real-world applications.
2 changes: 1 addition & 1 deletion docs/advanced_usage/3_multi_objective.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ use the method ``get_incumbents`` in the intensifier.
incumbents = smac.intensifier.get_incumbents()
```

We show an example of how to use multi-objective with plots in our [examples](../examples/3%20Multi-Objective/1_schaffer.html).
We show an example of how to use multi-objective with plots in our [examples](../examples/3%20Multi-Objective/1_schaffer.md).
2 changes: 1 addition & 1 deletion docs/advanced_usage/5.1_warmstarting.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TrialInfo:
```

## Usage Example
See [`examples/1_basics/8_warmstart.py`](../../examples/1%20Basics/8_warmstart.py).
See [`examples/1_basics/8_warmstart.py`](../examples/1%20Basics/8_warmstart.md).


```python
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced_usage/5_ask_and_tell.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ and report the results of the trial.
into the intensification process.


Please have a look at our [ask-and-tell example](../examples/1%20Basics/3_ask_and_tell.html).
Please have a look at our [ask-and-tell example](../examples/1%20Basics/3_ask_and_tell.md).
29 changes: 15 additions & 14 deletions docs/advanced_usage/8_logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Scenario(
...
)
```
Notably, if an output already exists at `./some_directory/experiment_name/seed`, the behavior is determined by the overwrite parameter in the [facade's][smac/facade/abstract_facade] settings. This parameter specifies whether to continue the previous run (default) or start a new run.
Notably, if an output already exists at `./some_directory/experiment_name/seed`, the behavior is determined by the overwrite parameter in the [facade's][smac.facade.abstract_facade] settings. This parameter specifies whether to continue the previous run (default) or start a new run.

The output is split into four different log files, and a copy of the utilized [Configuration Space of the ConfigSpace library](https://automl.github.io/ConfigSpace/latest/).

Expand Down Expand Up @@ -99,21 +99,22 @@ The runhistory.json in split into four parts. `stats`, `data`, `configs`, and `c
`data` contains a list of entries, one for each configuration.
```json
"data": [
[
1, # config_id
null, # instance or None
209652396, # seed or None
null, # budget or None
5.4345623938566385, # cost
6.699562072753906e-05, # time
6.299999999992423e-05, # cpu_time
1, # status
1733133181.2144582, # start_time
1733133181.21695, # end_time
{} # additional_info
],
{
"config_id": 1,
"instance": null,
"seed": 209652396,
"budget": 2.7777777777777777,
"cost": 2147483647.0,
"time": 0.0,
"cpu_time": 0.0,
"status": 0,
"starttime": 0.0,
"endtime": 0.0,
"additional_info": {}
},
...
]

```

`configs` is a human-readable dictionary of configurations, where the keys are the one-based `config_id`. It is important to note that in `runhistory.json`, the indexing is zero-based.
Expand Down
2 changes: 1 addition & 1 deletion docs/advanced_usage/9_parallelism.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SMAC supports multiple workers natively via Dask. Just specify ``n_workers`` in
## Running on a Cluster

You can also pass a custom dask client, e.g. to run on a slurm cluster.
See our [parallelism example](../examples/1%20Basics/7_parallelization_cluster.html).
See our [parallelism example](../examples/1%20Basics/7_parallelization_cluster.md).

!!! warning

Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"version": version,
"versions": {
f"v{version}": "#",
"v2.3.0": "https://automl.github.io/SMAC3/v2.3.0/",
"v2.2.0": "https://automl.github.io/SMAC3/v2.2.0/",
"v2.1.0": "https://automl.github.io/SMAC3/v2.1.0/",
"v2.0.1": "https://automl.github.io/SMAC3/v2.0.1/",
Expand Down
2 changes: 1 addition & 1 deletion examples/1_basics/1_quadratic_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from smac.facade.hyperparameter_optimization_facade import HyperparameterOptimizationFacade as HPOFacade
from smac import RunHistory, Scenario

__copyright__ = "Copyright 2021, AutoML.org Freiburg-Hannover"
__copyright__ = "Copyright 2025, Leibniz University Hanover, Institute of AI"
__license__ = "3-clause BSD"


Expand Down
2 changes: 1 addition & 1 deletion examples/1_basics/2_svm_cv.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from smac import HyperparameterOptimizationFacade, Scenario

__copyright__ = "Copyright 2021, AutoML.org Freiburg-Hannover"
__copyright__ = "Copyright 2025, Leibniz University Hanover, Institute of AI"
__license__ = "3-clause BSD"


Expand Down
2 changes: 1 addition & 1 deletion examples/1_basics/3_ask_and_tell.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from smac import HyperparameterOptimizationFacade, Scenario
from smac.runhistory.dataclasses import TrialValue

__copyright__ = "Copyright 2021, AutoML.org Freiburg-Hannover"
__copyright__ = "Copyright 2025, Leibniz University Hanover, Institute of AI"
__license__ = "3-clause BSD"


Expand Down
2 changes: 1 addition & 1 deletion examples/1_basics/4_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from smac import Scenario
from smac.runhistory import TrialInfo, TrialValue

__copyright__ = "Copyright 2021, AutoML.org Freiburg-Hannover"
__copyright__ = "Copyright 2025, Leibniz University Hanover, Institute of AI"
__license__ = "3-clause BSD"


Expand Down
2 changes: 1 addition & 1 deletion examples/1_basics/5_continue.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from smac.main.smbo import SMBO
from smac.runhistory import TrialInfo, TrialValue

__copyright__ = "Copyright 2021, AutoML.org Freiburg-Hannover"
__copyright__ = "Copyright 2025, Leibniz University Hanover, Institute of AI"
__license__ = "3-clause BSD"


Expand Down
79 changes: 73 additions & 6 deletions examples/1_basics/6_priors.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ConfigurationSpace,
NormalFloatHyperparameter,
UniformIntegerHyperparameter,
UniformFloatHyperparameter,
)
from sklearn.datasets import load_digits
from sklearn.exceptions import ConvergenceWarning
Expand All @@ -29,7 +30,7 @@
from smac import HyperparameterOptimizationFacade, Scenario
from smac.acquisition.function import PriorAcquisitionFunction

__copyright__ = "Copyright 2021, AutoML.org Freiburg-Hannover"
__copyright__ = "Copyright 2025, Leibniz University Hanover, Institute of AI"
__license__ = "3-clause BSD"


Expand All @@ -38,7 +39,7 @@

class MLP:
@property
def configspace(self) -> ConfigurationSpace:
def prior_configspace(self) -> ConfigurationSpace:
# Build Configuration Space which defines all parameters and their ranges.
# To illustrate different parameter types,
# we use continuous, integer and categorical parameters.
Expand Down Expand Up @@ -100,7 +101,67 @@ def configspace(self) -> ConfigurationSpace:
)

# Add all hyperparameters at once:
cs.add([n_layer, n_neurons, activation, optimizer, batch_size, learning_rate_init])
cs.add(
[n_layer, n_neurons, activation, optimizer, batch_size, learning_rate_init]
)

return cs

@property
def configspace(self) -> ConfigurationSpace:
# Build Configuration Space which defines all parameters and their ranges.
# To illustrate different parameter types,
# we use continuous, integer and categorical parameters.
cs = ConfigurationSpace()

# We do not have an educated belief on the number of layers beforehand
n_layer = UniformIntegerHyperparameter(
"n_layer",
lower=1,
upper=5,
)

# Define network width without a specific prior
n_neurons = UniformIntegerHyperparameter(
"n_neurons",
lower=8,
upper=256,
)

# Define activation functions without specific weights
activation = CategoricalHyperparameter(
"activation",
["logistic", "tanh", "relu"],
default_value="relu",
)

# Define optimizer without specific weights
optimizer = CategoricalHyperparameter(
"optimizer",
["sgd", "adam"],
default_value="adam",
)

# Define batch size without specific distribution
batch_size = UniformIntegerHyperparameter(
"batch_size",
16,
512,
default_value=128,
)

# Define learning rate range without log-normal prior
learning_rate_init = UniformFloatHyperparameter(
"learning_rate_init",
lower=1e-5,
upper=1.0,
default_value=1e-3,
)

# Add all hyperparameters at once:
cs.add(
[n_layer, n_neurons, activation, optimizer, batch_size, learning_rate_init]
)

return cs

Expand All @@ -119,8 +180,12 @@ def train(self, config: Configuration, seed: int = 0) -> float:
)

# Returns the 5-fold cross validation accuracy
cv = StratifiedKFold(n_splits=5, random_state=seed, shuffle=True) # to make CV splits consistent
score = cross_val_score(classifier, digits.data, digits.target, cv=cv, error_score="raise")
cv = StratifiedKFold(
n_splits=5, random_state=seed, shuffle=True
) # to make CV splits consistent
score = cross_val_score(
classifier, digits.data, digits.target, cv=cv, error_score="raise"
)

return 1 - np.mean(score)

Expand All @@ -140,7 +205,9 @@ def train(self, config: Configuration, seed: int = 0) -> float:

# We define the prior acquisition function, which conduct the optimization using priors over the optimum
acquisition_function = PriorAcquisitionFunction(
acquisition_function=HyperparameterOptimizationFacade.get_acquisition_function(scenario),
acquisition_function=HyperparameterOptimizationFacade.get_acquisition_function(
scenario
),
decay_beta=scenario.n_trials / 10, # Proven solid value
)

Expand Down
2 changes: 1 addition & 1 deletion examples/1_basics/7_parallelization_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

from smac import BlackBoxFacade, Scenario

__copyright__ = "Copyright 2023, AutoML.org Freiburg-Hannover"
__copyright__ = "Copyright 2025, Leibniz University Hanover, Institute of AI"
__license__ = "3-clause BSD"


Expand Down
2 changes: 1 addition & 1 deletion examples/2_multi_fidelity/1_mlp_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from smac.intensifier.hyperband import Hyperband
from smac.intensifier.successive_halving import SuccessiveHalving

__copyright__ = "Copyright 2021, AutoML.org Freiburg-Hannover"
__copyright__ = "Copyright 2025, Leibniz University Hanover, Institute of AI"
__license__ = "3-clause BSD"


Expand Down
2 changes: 1 addition & 1 deletion examples/2_multi_fidelity/2_sgd_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from smac import MultiFidelityFacade as MFFacade
from smac import Scenario

__copyright__ = "Copyright 2021, AutoML.org Freiburg-Hannover"
__copyright__ = "Copyright 2025, Leibniz University Hanover, Institute of AI"
__license__ = "3-clause BSD"


Expand Down
2 changes: 1 addition & 1 deletion examples/2_multi_fidelity/3_specify_HB_via_total_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from smac import MultiFidelityFacade, RunHistory, Scenario
from smac.intensifier.hyperband_utils import get_n_trials_for_hyperband_multifidelity

__copyright__ = "Copyright 2021, AutoML.org Freiburg-Hannover"
__copyright__ = "Copyright 2025, Leibniz University Hanover, Institute of AI"
__license__ = "3-clause BSD"


Expand Down
2 changes: 1 addition & 1 deletion examples/3_multi_objective/1_schaffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from smac import Scenario
from smac.facade import AbstractFacade

__copyright__ = "Copyright 2021, AutoML.org Freiburg-Hannover"
__copyright__ = "Copyright 2025, Leibniz University Hanover, Institute of AI"
__license__ = "3-clause BSD"


Expand Down
2 changes: 1 addition & 1 deletion examples/3_multi_objective/2_parego.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from smac.facade.abstract_facade import AbstractFacade
from smac.multi_objective.parego import ParEGO

__copyright__ = "Copyright 2021, AutoML.org Freiburg-Hannover"
__copyright__ = "Copyright 2025, Leibniz University Hanover, Institute of AI"
__license__ = "3-clause BSD"


Expand Down
Loading

0 comments on commit d2cbb7b

Please sign in to comment.