Skip to content
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

ModuleNotFoundError: No module named 'gluonts.dataset.rolling_dataset' #3219

Open
satyrmipt opened this issue Sep 15, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@satyrmipt
Copy link

Description

Looking for feature implemented here: #844
Previously it could be found here: https://ts.gluon.ai/v0.11.x/api/gluonts/gluonts.dataset.rolling_dataset.html
Currently the code
from gluonts.dataset.rolling_dataset import StepStrategy, generate_rolling_dataset
returns
ModuleNotFoundError: No module named 'gluonts.dataset.rolling_dataset'

To Reproduce

  1. Google colab
  2. pip install "gluonts[torch]==0.15"
    Result:
Requirement already satisfied: gluonts==0.15 in /usr/local/lib/python3.10/dist-packages (from gluonts[torch]==0.15) (0.15.0)
Requirement already satisfied: numpy~=1.16 in /usr/local/lib/python3.10/dist-packages (from gluonts==0.15->gluonts[torch]==0.15) (1.26.4)
Requirement already satisfied: pandas<3,>=1.0 in /usr/local/lib/python3.10/dist-packages (from gluonts==0.15->gluonts[torch]==0.15) (2.1.4)
Requirement already satisfied: pydantic<3,>=1.7 in /usr/local/lib/python3.10/dist-packages (from gluonts==0.15->gluonts[torch]==0.15) (2.9.1)
Requirement already satisfied: tqdm~=4.23 in /usr/local/lib/python3.10/dist-packages (from gluonts==0.15->gluonts[torch]==0.15) (4.66.5)
Requirement already satisfied: toolz~=0.10 in /usr/local/lib/python3.10/dist-packages (from gluonts==0.15->gluonts[torch]==0.15) (0.12.1)
Requirement already satisfied: typing-extensions~=4.0 in /usr/local/lib/python3.10/dist-packages (from gluonts==0.15->gluonts[torch]==0.15) (4.12.2)
Requirement already satisfied: torch<3,>=1.9 in /usr/local/lib/python3.10/dist-packages (from gluonts[torch]==0.15) (2.4.0+cu121)
Requirement already satisfied: lightning<2.2,>=2.0 in /usr/local/lib/python3.10/dist-packages (from gluonts[torch]==0.15) (2.1.4)
Requirement already satisfied: pytorch-lightning<2.2,>=2.0 in /usr/local/lib/python3.10/dist-packages (from gluonts[torch]==0.15) (2.1.4)
Requirement already satisfied: scipy~=1.10 in /usr/local/lib/python3.10/dist-packages (from gluonts[torch]==0.15) (1.13.1)
Requirement already satisfied: PyYAML<8.0,>=5.4 in /usr/local/lib/python3.10/dist-packages (from lightning<2.2,>=2.0->gluonts[torch]==0.15) (6.0.2)
Requirement already satisfied: fsspec<2025.0,>=2022.5.0 in /usr/local/lib/python3.10/dist-packages (from fsspec[http]<2025.0,>=2022.5.0->lightning<2.2,>=2.0->gluonts[torch]==0.15) (2024.6.1)
Requirement already satisfied: lightning-utilities<2.0,>=0.8.0 in /usr/local/lib/python3.10/dist-packages (from lightning<2.2,>=2.0->gluonts[torch]==0.15) (0.11.7)
Requirement already satisfied: packaging<25.0,>=20.0 in /usr/local/lib/python3.10/dist-packages (from lightning<2.2,>=2.0->gluonts[torch]==0.15) (24.1)
Requirement already satisfied: torchmetrics<3.0,>=0.7.0 in /usr/local/lib/python3.10/dist-packages (from lightning<2.2,>=2.0->gluonts[torch]==0.15) (1.4.2)
Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas<3,>=1.0->gluonts==0.15->gluonts[torch]==0.15) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3,>=1.0->gluonts==0.15->gluonts[torch]==0.15) (2024.2)
Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas<3,>=1.0->gluonts==0.15->gluonts[torch]==0.15) (2024.1)
Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1.7->gluonts==0.15->gluonts[torch]==0.15) (0.7.0)
Requirement already satisfied: pydantic-core==2.23.3 in /usr/local/lib/python3.10/dist-packages (from pydantic<3,>=1.7->gluonts==0.15->gluonts[torch]==0.15) (2.23.3)
Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from torch<3,>=1.9->gluonts[torch]==0.15) (3.16.0)
Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch<3,>=1.9->gluonts[torch]==0.15) (1.13.2)
Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch<3,>=1.9->gluonts[torch]==0.15) (3.3)
Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch<3,>=1.9->gluonts[torch]==0.15) (3.1.4)
Requirement already satisfied: aiohttp!=4.0.0a0,!=4.0.0a1 in /usr/local/lib/python3.10/dist-packages (from fsspec[http]<2025.0,>=2022.5.0->lightning<2.2,>=2.0->gluonts[torch]==0.15) (3.10.5)
Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from lightning-utilities<2.0,>=0.8.0->lightning<2.2,>=2.0->gluonts[torch]==0.15) (71.0.4)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.2->pandas<3,>=1.0->gluonts==0.15->gluonts[torch]==0.15) (1.16.0)
Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->torch<3,>=1.9->gluonts[torch]==0.15) (2.1.5)
Requirement already satisfied: mpmath<1.4,>=1.1.0 in /usr/local/lib/python3.10/dist-packages (from sympy->torch<3,>=1.9->gluonts[torch]==0.15) (1.3.0)
Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<2025.0,>=2022.5.0->lightning<2.2,>=2.0->gluonts[torch]==0.15) (2.4.0)
Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<2025.0,>=2022.5.0->lightning<2.2,>=2.0->gluonts[torch]==0.15) (1.3.1)
Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<2025.0,>=2022.5.0->lightning<2.2,>=2.0->gluonts[torch]==0.15) (24.2.0)
Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<2025.0,>=2022.5.0->lightning<2.2,>=2.0->gluonts[torch]==0.15) (1.4.1)
Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<2025.0,>=2022.5.0->lightning<2.2,>=2.0->gluonts[torch]==0.15) (6.1.0)
Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<2025.0,>=2022.5.0->lightning<2.2,>=2.0->gluonts[torch]==0.15) (1.11.1)
Requirement already satisfied: async-timeout<5.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<2025.0,>=2022.5.0->lightning<2.2,>=2.0->gluonts[torch]==0.15) (4.0.3)
Requirement already satisfied: idna>=2.0 in /usr/local/lib/python3.10/dist-packages (from yarl<2.0,>=1.0->aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<2025.0,>=2022.5.0->lightning<2.2,>=2.0->gluonts[torch]==0.15) (3.8)
  1. from gluonts.dataset.rolling_dataset import StepStrategy, generate_rolling_dataset
    Result:
ModuleNotFoundError                       Traceback (most recent call last)
[<ipython-input-3-496fc7eec3ae>](https://localhost:8080/#) in <cell line: 10>()
      8 
      9 from gluonts.dataset.pandas import PandasDataset
---> 10 from gluonts.dataset.rolling_dataset import StepStrategy, generate_rolling_dataset
     11 
     12 with open("/content/drive/MyDrive/Colab Notebooks/quantgem/params.yaml") as params:

ModuleNotFoundError: No module named 'gluonts.dataset.rolling_dataset'

Environment

@satyrmipt satyrmipt added the bug Something isn't working label Sep 15, 2024
@satyrmipt
Copy link
Author

Looks like rolling dataset approach changed somewhere between recommended version (0.12.*) and 0.15. The later one allows you to create rolling dataset as

gluon_ds=PandasDataset.from_long_dataframe(
    dataframe=normal_df,
    target='target',
    item_id='item_id',
    freq=FREQ
)

splitter = OffsetSplitter(offset=offset)
train_ds, test_template = splitter.split(gluon_ds)

test_ds = test_template.generate_instances(
    prediction_length=PREDICTION_LENGTH,
    windows=ROLL_PERIODS,
    distance=ROLLING_STEP_SIZE
)
print(train_ds)
print(test_ds)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant