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

Error in predict_insample() with Variable-Length Timeseries #1216

Open
aitirga opened this issue Nov 25, 2024 · 2 comments
Open

Error in predict_insample() with Variable-Length Timeseries #1216

aitirga opened this issue Nov 25, 2024 · 2 comments
Labels

Comments

@aitirga
Copy link

aitirga commented Nov 25, 2024

What happened + What you expected to happen

When using the predict_insample() method on an NHITS model with a DataFrame containing multiple timeseries of varying lengths, the following error occurs

Traceback (most recent call last):
...
/site-packages/neuralforecast/core.py", line 1410, in predict_insample
    fcsts[:, col_idx : (col_idx + output_length)] = model_fcsts
    ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: could not broadcast input array from shape (960,1) into shape (660,1)

Versions / Dependencies

I am using a macos OS with python 3.11.10 and neuralforecast 1.7.6

Reproduction script

import neuralforecast as nf
from neuralforecast.models import NHITS
import pandas as pd

if __name__ == '__main__':
    df = pd.DataFrame()
    df['ds'] = pd.date_range(start='1/1/2018', periods=100, freq='D')
    df['y'] = range(100)
    df['unique_id'] = 'station_1'
    df_additional = pd.DataFrame({
        'ds': pd.date_range(start='1/1/2017', periods=40, freq='D'),
        'y': range(40),
        'unique_id': ['station_2']*40,
    })
    df = pd.concat([df, df_additional], ignore_index=True)
    model = NHITS(h=5, input_size=7, accelerator='cpu', max_steps=5)
    nf_model = nf.NeuralForecast(models=[model], freq='D')
    nf_model.fit(df)
    nf_model.predict_insample()

Issue Severity

High: It blocks me from completing my task.

@aitirga aitirga added the bug label Nov 25, 2024
@marcopeix
Copy link
Contributor

Can reproduce the error, thanks for pointing it out! We'll work on a fix.

@marcopeix marcopeix changed the title Error in predict_insample() with Variable-Length Timeseries in NHITS Model Error in predict_insample() with Variable-Length Timeseries Nov 26, 2024
@jmoralez
Copy link
Member

We already have some issues about this:

It'd be good to choose one and concentrate the discussion there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants