Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11"]
os: ["ubuntu-latest"]

steps:
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11"]
os: ["ubuntu-latest"]

steps:
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10", "3.11"]
os: ["ubuntu-latest"]

steps:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.4.0
## Improvements
- Replace random forest from pyrfr with random forest from sklearn (#1246)

# 2.3.1

## Bugfixes
Expand Down
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ conda create -n SMAC python=3.10
conda activate SMAC
```

Install swig:
```
conda install gxx_linux-64 gcc_linux-64 swig
```

Install SMAC via PyPI:
```
pip install smac
Expand All @@ -63,6 +58,20 @@ git clone https://github.com/automl/SMAC3.git && cd SMAC3
make install-dev
```

## Running SMAC with pyrfr
starting from 2.4.0, SMAC uses random forest from [sklearn](https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestRegressor.html)
instead of random forest from [pyrfr](https://pypi.org/project/pyrfr/) as the default surrogate model for HPO tasks.
However, you could still use the old pyrfr surrogate model by calling `smac.facade.old.HyperparameterOptimizationRFRFacade`
and `smac.facade.old.MultiFidelityRFRFacade`

To work with pyrfr, you need to first install gcc, gxx, and swig:
```
conda install gxx_linux-64 gcc_linux-64 swig
```
then install smac with the pyrfr option:
```
pip install smac[pyrfr]
```

## Minimal Example

Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def read_file(filepath: str) -> str:


extras_require = {
"pyrfr": [
"pyrfr>=0.9.0",
],
"dev": [
"setuptools",
"types-setuptools",
Expand Down Expand Up @@ -79,8 +82,7 @@ def read_file(filepath: str) -> str:
"pynisher>=1.0.0",
"ConfigSpace>=1.0.0",
"joblib",
"scikit-learn>=1.1.2",
"pyrfr>=0.9.0",
"scikit-learn>=1.6.1",
"dask[distributed]",
"dask_jobqueue>=0.8.2",
"emcee>=3.0.0",
Expand Down
9 changes: 9 additions & 0 deletions smac/facade/old/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from smac.facade.old.hyperparameter_optimization_facade_pyrfr import (
HyperparameterOptimizationRFRFacade,
)
from smac.facade.old.multi_fidelity_facade_pyrfr import MultiFidelityRFRFacade

__all__ = [
"HyperparameterOptimizationRFRFacade",
"MultiFidelityRFRFacade",
]
50 changes: 50 additions & 0 deletions smac/facade/old/hyperparameter_optimization_facade_pyrfr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from __future__ import annotations

from smac.facade.hyperparameter_optimization_facade import (
HyperparameterOptimizationFacade,
)
from smac.model.random_forest.pyrfr.random_forest_pyrfr import PyrfrRandomForest
from smac.scenario import Scenario


class HyperparameterOptimizationRFRFacade(HyperparameterOptimizationFacade):
@staticmethod
def get_model( # type: ignore
scenario: Scenario,
*,
n_trees: int = 10,
ratio_features: float = 1.0,
min_samples_split: int = 2,
min_samples_leaf: int = 1,
max_depth: int = 2**20,
bootstrapping: bool = True,
) -> PyrfrRandomForest:
"""Returns a random forest as surrogate model.

Parameters
----------
n_trees : int, defaults to 10
The number of trees in the random forest.
ratio_features : float, defaults to 5.0 / 6.0
The ratio of features that are considered for splitting.
min_samples_split : int, defaults to 3
The minimum number of data points to perform a split.
min_samples_leaf : int, defaults to 3
The minimum number of data points in a leaf.
max_depth : int, defaults to 20
The maximum depth of a single tree.
bootstrapping : bool, defaults to True
Enables bootstrapping.
"""
return PyrfrRandomForest(
log_y=True,
n_trees=n_trees,
bootstrapping=bootstrapping,
ratio_features=ratio_features,
min_samples_split=min_samples_split,
min_samples_leaf=min_samples_leaf,
max_depth=max_depth,
configspace=scenario.configspace,
instance_features=scenario.instance_features,
seed=scenario.seed,
)
13 changes: 13 additions & 0 deletions smac/facade/old/multi_fidelity_facade_pyrfr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from __future__ import annotations

from smac.facade.multi_fidelity_facade import MultiFidelityFacade
from smac.facade.old.hyperparameter_optimization_facade_pyrfr import (
HyperparameterOptimizationRFRFacade,
)

__copyright__ = "Copyright 2022, automl.org"
__license__ = "3-clause BSD"


class MultiFidelityRFRFacade(MultiFidelityFacade, HyperparameterOptimizationRFRFacade):
pass
Empty file.
Loading
Loading