ServiceNow / TACTiS

TACTiS-2: Better, Faster, Simpler Attentional Copulas for Multivariate Time Series, from ServiceNow Research
Apache License 2.0
110 stars 19 forks source link

Notebooks TypeError: '>=' not supported between instances of 'Timestamp' and 'Period' #11

Closed ivanvoid closed 1 year ago

ivanvoid commented 1 year ago

Hi, amazing paper. For all demo notebooks that includes data (gluon_electricity.ipynb, gluon_fred_md.ipynb, gluon_solar.ipynb) got similar errors, in generate datasets parts (3ed code cell):

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/ivan/Projects/tactis/demo/gluon_solar.ipynb Cell 5 in <cell line: 4>()
      [1](vscode-notebook-cell:/home/ivan/Projects/tactis/demo/gluon_solar.ipynb#W4sZmlsZQ%3D%3D?line=0) history_factor = 2
      [2](vscode-notebook-cell:/home/ivan/Projects/tactis/demo/gluon_solar.ipynb#W4sZmlsZQ%3D%3D?line=1) backtest_id = 4
----> [4](vscode-notebook-cell:/home/ivan/Projects/tactis/demo/gluon_solar.ipynb#W4sZmlsZQ%3D%3D?line=3) metadata, train_data, test_data = generate_backtesting_datasets("solar_10min", backtest_id, history_factor)

File ~/Projects/tactis/tactis/gluon/dataset.py:305, in generate_backtesting_datasets(name, backtest_id, history_length_multiple, use_cached)
    303 train_data = []
    304 for i, series in enumerate(raw_dataset):
--> 305     train_end_index = _count_timesteps(series["start"], backtest_timestamp, timestep_delta)
    307     s_train = series.copy()
    308     s_train["target"] = series["target"][:train_end_index]

File ~/Projects/tactis/tactis/gluon/dataset.py:117, in _count_timesteps(left, right, delta)
    112 def _count_timesteps(left: pd.Timestamp, right: pd.Timestamp, delta: pd.DateOffset) -> int:
    113     """
    114     Count how many timesteps there are between left and right, according to the given timesteps delta.
    115     If the number if not integer, round down.
    116     """
--> 117     assert right >= left, f"Case where left ({left}) is after right ({right}) is not implemented in _count_timesteps()."
    118     try:
    119         return (right - left) // delta

TypeError: '>=' not supported between instances of 'Timestamp' and 'Period'
ivanvoid commented 1 year ago

ok fixed it. https://github.com/ServiceNow/tactis/pull/12

marcotet commented 1 year ago

After investigation, this is due to GluonTS replacing Timestamp by Period for version 0.10.0. We only tested on version 0.9.4, so we missed it.

marcotet commented 1 year ago

Fixed (for GluonTS versions 0.10.0 and above) in #12