Skip to content

ENH: Add tqdm to skopt optimization #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 31, 2021
5 changes: 4 additions & 1 deletion backtesting/backtesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1352,7 +1352,8 @@ def _batch(seq):
with ProcessPoolExecutor() as executor:
futures = [executor.submit(Backtest._mp_task, backtest_uuid, i)
for i in range(len(param_batches))]
for future in _tqdm(as_completed(futures), total=len(futures)):
for future in _tqdm(as_completed(futures), total=len(futures),
desc='Backtest.optimize'):
batch_index, values = future.result()
for value, params in zip(values, param_batches[batch_index]):
heatmap[tuple(params.values())] = value
Expand Down Expand Up @@ -1420,9 +1421,11 @@ def _optimize_skopt() -> Union[pd.Series,

# np.inf/np.nan breaks sklearn, np.finfo(float).max breaks skopt.plots.plot_objective
INVALID = 1e300
progress = iter(_tqdm(repeat(None), total=max_tries, desc='Backtest.optimize'))

@use_named_args(dimensions=dimensions)
def objective_function(**params):
next(progress)
# Check constraints
# TODO: Adjust after https://github.com/scikit-optimize/scikit-optimize/pull/971
if not constraint(AttrDict(params)):
Expand Down