Nixtla / neuralforecast

Scalable and user friendly neural :brain: forecasting algorithms.
https://nixtlaverse.nixtla.io/neuralforecast
Apache License 2.0
3.14k stars 363 forks source link

[<Library component: Model|Core|etc...>] How to forecast unknown periods with Nan? #1221

Open skmanzg opened 10 hours ago

skmanzg commented 10 hours ago

What happened + What you expected to happen

goal: try to forecast data of the future period when there is no original data of the period.

I tried to use Y_test_df like the example of the document when its period are the next period of the original data. Since there is no original data in its future data, it is full of NaN. (y is full of nan). Y_train_df is equal to the original data in this case.

and the error appears when I run this: forecasts = nf.predict(futr_df=Y_test_df)

ValueError: There are missing combinations of ids and times in futr_df. You can run the make_future_dataframe() method to get the expected combinations or the get_missing_future(futr_df) method to get the missing combinations.

Time Series forecasting is to forecast unknown period but I do not know how to apply for practical usage like this? According to this error, it requires original data but I am not forecasting to observe how good forecast the model does. Please guide me to forecast in practical usage.

Versions / Dependencies

python 3.10

Reproduction script

model = iTransformer(
    h=186,
    input_size=372,  
    n_series=5,
    scaler_type='minmax',
    max_steps=500,
    early_stop_patience_steps=3,
    val_check_steps=50,
    # learning_rate=1e-3,
    loss=MSE(),
    valid_loss=MAE(),
    batch_size=32,

    factor=5,
    n_heads=5,
    e_layers=5,
    d_layers=5,

    accelerator='auto', 
    devices='auto',
    enable_model_summary=False,
    enable_progress_bar=True
)

nf = NeuralForecast(models=[model], freq='10min') 

nf.fit(df=Y_train_df, val_size=474)

forecasts = nf.predict(futr_df=Y_test_df)

Y_test_df is full of Nan in the next future period of the original data.

Issue Severity

High: It blocks me from completing my task.

marcopeix commented 3 hours ago

Hello! If I understand correctly, you don't need to pass a df when calling predict(). Simply fit the model like you did and call nf.predict(). This will make predictions starting from the end of Y_train_df for a horizon of 186.

If you pass a df to predict(), then you're asking the model to take this data as input and forecast the horizon following it. In your case, you don't have any values, so that causes the error.

Does that make sense? Let me know if that answers your question!