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

What is the purpose of unique_id during prediction? Different unique_id values produce the same prediction results. #1162

Closed
sunggc opened this issue Sep 29, 2024 · 1 comment
Labels

Comments

@sunggc
Copy link

sunggc commented Sep 29, 2024

What happened + What you expected to happen

nf = NeuralForecast(models=models, freq='M')
nf.fit(df=Y_df)

df_HUFL = Y_df[Y_df['unique_id'] == 'HUFL'].tail(48)

preds = nf.predict(df_HUFL)
print(preds.head(12))
df_HULL = df_HUFL.copy()
df_HULL['unique_id'] = 'HULL'

preds_HULL = nf.predict(df_HULL)
print(preds_HULL.head(12))

preds is the same as preds_HULL

Versions / Dependencies

1.7.5

Reproduction script

from datasetsforecast.long_horizon import LongHorizon

Change this to your own data to try the model

Y_df, _, _ = LongHorizon.load(directory='./', group='ETTm2')
print(Y_df.head())

打印Y_df 中不同的unique_id

print(Y_df['unique_id'].unique())
horizon = 12
Y_df['ds'] = pd.to_datetime(Y_df['ds'])

Try different hyperparmeters to improve accuracy.

models = [LSTM(h=horizon, # Forecast horizon
max_steps=100, # Number of steps to train
scaler_type='standard', # Type of scaler to normalize data
encoder_hidden_size=64, # Defines the size of the hidden state of the LSTM
decoder_hidden_size=64,), # Defines the number of hidden units of each layer of the MLP decoder
NHITS(h=horizon, # Forecast horizon
input_size=2 * horizon, # Length of input sequence
max_steps=100, # Number of steps to train
n_freq_downsample=[2, 1, 1]) # Downsampling factors for each stack output
]
nf = NeuralForecast(models=models, freq='M')
nf.fit(df=Y_df)

df_HUFL = Y_df[Y_df['unique_id'] == 'HUFL'].tail(48)

preds = nf.predict(df_HUFL)
print(preds.head(12))
df_HULL = df_HUFL.copy()
df_HULL['unique_id'] = 'HULL'

preds_HULL = nf.predict(df_HULL)
print(preds_HULL.head(12))

Issue Severity

None

@sunggc sunggc added the bug label Sep 29, 2024
@elephaint
Copy link
Contributor

Thanks for using NeuralForecast!

As stated in the documentation:
Y_df is a dataframe with three columns: unique_id with a unique identifier for each time series, a column ds with the datestamp and a column y with the values of the series.

With neural models you typically train a single model for multiple time series. If you only have a single time series, the value of unique_id will not matter.

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

2 participants