Skip to content

A problem of using NeuralForecast.predict_insample #1346

Open
@Firefighter1992

Description

@Firefighter1992

Dear sir,
Here is my code, which uses LSTM for multi-step forecasting. I have set the stat_exog_list parameter. However, when I use the predict_insample method, I cannot find a way to pass my static exogenous variables. The following error occurs:
Exception: {'heat_release_rate_kw'} static exogenous variables not found in input dataset.
However, it seems that predict_insample does not accept static exogenous variables as an argument. How should I resolve this issue?

The following is my code:
import pandas as pd
import matplotlib
matplotlib.use('TkAgg')

import matplotlib.pyplot as plt
from neuralforecast import NeuralForecast
from neuralforecast.models import LSTM
from neuralforecast.losses.pytorch import DistributionLoss

file_path = r"E:\NeuralForecast\Temperature.csv"

temp = pd.read_csv(file_path)
temp['ds'] = temp['ds'].astype(int)

Y_train_df = temp[temp.ds < temp['ds'].values[-12]]
Y_test_df = temp[temp.ds >= temp['ds'].values[-12]].reset_index(drop=True)

tempStatic = pd.DataFrame({
'unique_id': [25, 50, 100, 200],
'heat_release_rate_kw': [25, 50, 100, 200]
})

horizon=6
nf = NeuralForecast(
models=[LSTM(h=horizon,
input_size=12,
loss=DistributionLoss(distribution="Normal", level=[80, 90]),
scaler_type='robust',
encoder_n_layers=2,
encoder_hidden_size=128,
decoder_hidden_size=256,
decoder_layers=4,
max_steps=400,
futr_exog_list=[],
stat_exog_list=['heat_release_rate_kw'],
recurrent=True,
)
],
freq=1
)

#This sentence is the error source
Y_hat_df_train = nf.predict_insample(step_size = horizon)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions