Skip to content

Commit d33e931

Browse files
committed
early stop - replace values lower than 20 with 20 and display a warning.
1 parent 28e5efc commit d33e931

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

docs/hyperopt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ freqtrade hyperopt --config config.json --hyperopt-loss <hyperoptlossname> --str
490490
```
491491

492492
The `-e` option will set how many evaluations hyperopt will do. Since hyperopt uses Bayesian search, running too many epochs at once may not produce greater results. Experience has shown that best results are usually not improving much after 500-1000 epochs.
493-
The `--early-stop` option will set after how many epochs with no improvements hyperopt will stop. A good value is 20-30% of the total epochs. Early stop is by default disabled (`--early-stop=0`)
493+
The `--early-stop` option will set after how many epochs with no improvements hyperopt will stop. A good value is 20-30% of the total epochs. Any value greater than 0 and lower than 20 it will be replaced by 20. Early stop is by default disabled (`--early-stop=0`)
494494

495495
Doing multiple runs (executions) with a few 1000 epochs and different random state will most likely produce different results.
496496

freqtrade/configuration/configuration.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,16 @@ def _process_optimize_options(self, config: Config) -> None:
334334
("print_all", "Parameter --print-all detected ..."),
335335
]
336336
self._args_to_config_loop(config, configurations)
337-
if self.args.get("early_stop", 0) > 0:
338-
config.update({"early_stop": self.args["early_stop"]})
337+
es_epochs = self.args.get("early_stop", 0)
338+
if es_epochs > 0:
339+
if es_epochs < 20:
340+
logger.warning(
341+
f"Early stop epochs {es_epochs} lower than 20. "
342+
f"It will be replaced with 20."
343+
)
344+
config.update({"early_stop": 20})
345+
else:
346+
config.update({"early_stop": self.args["early_stop"]})
339347
logger.info(
340348
f"Parameter --early-stop detected ... Will early stop hyperopt if no improvement "
341349
f"after {self.args.get('early_stop')} epochs ..."

0 commit comments

Comments
 (0)