I'm struggling to visualize the performance of the timeLLM model on the Ehtt1 dataset. .py
The forecast function returns predictions and actuals as a NumPy array:
predictions, actuals = forecast (inputs)
# shape of prediction and actuals [1812, 16, 96, 1]
1812 represents the test dataset size, 16 is the batch size, 96 is the forecast horizon, and 1 is the number of features.
My goal is to plot the last 200 predictions against their corresponding actual values.
I've made several attempts, but the resulting plots seem inconsistent with reality. Can you help me identify the correct approach to achieve this visualization?
My attampts include:
# Aggregate predictions and actuals across batches (flatten all batches and time steps)
all_predictions = predictions[:, :, :, 0].flatten() # Shape: (1218 * 16 * 96,)
all_actuals = actuals[:, :, :, 0].flatten() # Shape: (1218 * 16 * 96,)
# Slice the last 200 values
last_200_predictions = all_predictions[-200:]
last_200_actuals = all_actuals[-200:]
and
# Select a specific batch (e.g., batch 0)
batch_index = 0
# Extract predictions and actuals for the selected batch
batch_predictions = predictions[:, batch_index, :, 0] # Shape: (1218, 96)
batch_actuals = actuals[:, batch_index, :, 0] # Shape: (1218, 96)
# Select a specific time series (e.g., the first one in the batch)
time_series_index = 0
# Extract the prediction and actual values for the selected time series
prediction__m = batch_predictions[time_series_index] # Shape: (96,)
actual__m = batch_actuals[time_series_index] # Shape: (96,)
# Focus on the last 200 values
# Since the horizon length is 96, we need to handle cases where 200 > 96
# If you want to compare across multiple batches or time steps, you may need to
concatenate data.
# If you want to compare the last 200 values across multiple batches or time series:
# Concatenate predictions and actuals along the time axis (if needed)
all_predictions = predictions[:, batch_index, :, 0].flatten() # Flatten to get all
time
steps
all_actuals = actuals[:, batch_index, :, 0].flatten() # Flatten to get all
time
steps
# Slice the last 200 values
last_200_predictions = all_predictions[-200:]
last_200_actuals = all_actuals[-200:]