admin管理员组文章数量:1316304
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:]
版权声明:本文标题:How to Plot Predictions vs. Actual Values in Time Series Forecasting with 4D NumPy Arrays? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742004522a2411691.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论