* add disable_tqdm flag to diagnostics.py

* add comment to cross_validation()

* Replace boolean comparison operator

Co-authored-by: Marius Theiss <justusbersten@gmail.com>

* Fix indentation

* Restore original indentation

Co-authored-by: Filippo Bonaita <filippo.bonaita@corp.badoo.com>
Co-authored-by: Marius Theiss <justusbersten@gmail.com>
This commit is contained in:
fbonaita 2020-11-07 05:02:54 +00:00 committed by GitHub
parent e41ed25646
commit 3a17402585
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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