Skip to content

Commit 87061bc

Browse files
committed
docs: adopt autosampler example as advanced hyperopt approach
1 parent a6d3995 commit 87061bc

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

docs/advanced-hyperopt.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,36 @@ Some research will be necessary to find additional Samplers (from optunahub) for
179179
While custom estimators can be provided, it's up to you as User to do research on possible parameters and analyze / understand which ones should be used.
180180
If you're unsure about this, best use one of the Defaults (`"NSGAIIISampler"` has proven to be the most versatile) without further parameters.
181181

182+
??? Example "Using `AutoSampler` from Optunahub"
183+
184+
[AutoSampler docs](https://hub.optuna.org/samplers/auto_sampler/)
185+
186+
Install the necessary dependencies
187+
``` bash
188+
pip install optunahub cmaes torch scipy
189+
```
190+
Implement `generate_estimator()` in your strategy
191+
192+
``` python
193+
# ...
194+
from freqtrade.strategy.interface import IStrategy
195+
from typing import List
196+
import optunahub
197+
# ...
198+
199+
class my_strategy(IStrategy):
200+
class HyperOpt:
201+
def generate_estimator(dimensions: List["Dimension"], **kwargs):
202+
if "random_state" in kwargs.keys():
203+
return optunahub.load_module("samplers/auto_sampler").AutoSampler(seed=kwargs["random_state"])
204+
else:
205+
return optunahub.load_module("samplers/auto_sampler").AutoSampler()
206+
207+
```
208+
209+
Obviously the same approach will work for all other Samplers optuna supports.
210+
211+
182212
## Space options
183213

184214
For the additional spaces, scikit-optimize (in combination with Freqtrade) provides the following space types:

0 commit comments

Comments
 (0)