From 3a17402585198637ba1b154c10c1198eb0f6bfb8 Mon Sep 17 00:00:00 2001 From: fbonaita <64653468+fbonaita@users.noreply.github.com> Date: Sat, 7 Nov 2020 05:02:54 +0000 Subject: [PATCH] Tqdm flag (#1706) * add disable_tqdm flag to diagnostics.py * add comment to cross_validation() * Replace boolean comparison operator Co-authored-by: Marius Theiss * Fix indentation * Restore original indentation Co-authored-by: Filippo Bonaita Co-authored-by: Marius Theiss --- python/fbprophet/diagnostics.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/python/fbprophet/diagnostics.py b/python/fbprophet/diagnostics.py index 2cef024..40fc38d 100644 --- a/python/fbprophet/diagnostics.py +++ b/python/fbprophet/diagnostics.py @@ -58,7 +58,7 @@ def generate_cutoffs(df, horizon, initial, period): return list(reversed(result)) -def cross_validation(model, horizon, period=None, initial=None, parallel=None, cutoffs=None): +def cross_validation(model, horizon, period=None, initial=None, parallel=None, cutoffs=None, disable_tqdm=False): """Cross-Validation for time series. Computes forecasts from historical cutoff points, which user can input. @@ -79,9 +79,10 @@ def cross_validation(model, horizon, period=None, initial=None, parallel=None, c period will include at least this much data. If not provided, 3 * horizon is used. cutoffs: list of pd.Timestamp specifying cutoffs to be used during - cross validtation. If not provided, they are generated as described + cross validation. If not provided, they are generated as described above. parallel : {None, 'processes', 'threads', 'dask', object} + disable_tqdm: if True it disables the progress bar that would otherwise show up when parallel=None How to parallelize the forecast computation. By default no parallelism is used. @@ -185,8 +186,8 @@ def cross_validation(model, horizon, period=None, initial=None, parallel=None, c else: predicts = [ - single_cutoff_forecast(df, model, cutoff, horizon, predict_columns) - for cutoff in tqdm(cutoffs) + single_cutoff_forecast(df, model, cutoff, horizon, predict_columns) + for cutoff in (tqdm(cutoffs) if not disable_tqdm else cutoffs) ] # Combine all predicted pd.DataFrame into one pd.DataFrame