Hello. Could someone please help me? I want to use...
# general
a
Hello. Could someone please help me? I want to use the informer model available in the neural forecast in my own csv file. I have multivariate data in which columns are there in this way: date, var1(t-1), var2(t-1), and var1(t) where var1(t) is the target variable and others are feature variables except the date. I want to split my data into test and train only and do prediction analysis. Plus, I want to save my data in csv file. Someone please provide the code or assistance with it. I'll be very grateful to you.
m
It would be something like:
Copy code
import pandas as pd
from neuralforecast import NeuralForecast
from neuralforecast.models import Informer

model = Informer(h=12,
                 input_size=24,
                 futr_exog_list=[var1,var2])

nf = NeuralForecast(
    models=[model],
    freq=your_data_freq
)

nf.fit(df=training_set)
forecasts = nf.predict(
forecasts.to_csv(path)
The documentation for Informer is here.
a
Thank you so much for your reply. One more thing, I've attached my dataset. Can you please let me know if I have to make some changes as per the code requirement? This is my dataset.
m
In the code, we do expect the date column to be called
ds
and the target column to be called
y
. Maybe changing those column names will make it easier
a
Okay. I've done changes in my dataset. But I am getting error. Here is my code import pandas as pd from neuralforecast import NeuralForecast from neuralforecast.models import Informer from neuralforecast.losses.pytorch import MAE from sklearn.model_selection import train_test_split Y_df = pd.read_csv('lai_supervised.csv') Y_df['ds'] = pd.to_datetime(Y_df['ds']) X = Y_df[['var1(t-1)', 'var2(t-1)']] Y = Y_df['y'] # Split data into train and test sets train_X, test_X, train_y, test_y = train_test_split(X, Y, test_size = 0.2, random_state = 0) training_df = pd.DataFrame({ 'ds': train_X.index, # Assuming train_X has a datetime index 'var1(t-1)': train_X['var1(t-1)'], 'var2(t-1)': train_X['var2(t-1)'], 'y': train_y }) model = Informer(h=12, input_size=24, futr_exog_list=[['var1(t-1)','var2(t-1)']] ) nf = NeuralForecast( models=[model], freq=1 ) nf.fit(df=training_df) forecasts = nf.predict() forecasts.to_csv('forecast.csv') error is related to unique_id. Kindly help me
m
The library expects a
unique_id
column that identifies each series. If you have a single series, the column should have a constant value. Please, read our quickstart guide to get started with neuralforecast.
a
Thank you for your reply