zhihanyue / ts2vec

A universal time series representation learning framework
MIT License
612 stars 146 forks source link

Question on Plotting #18

Open vageeshmaiya opened 2 years ago

vageeshmaiya commented 2 years ago

I have run the code for ETTh2 dataset as mentioned in the paper for 500 epochs and have obtained the pickle file as output. I am trying to get the plot of prediction v/s ground truth as mentioned in the paper in Figure 5. Could you please suggest the code used to plot the obtained output.

zifei-yu commented 1 year ago

Hello, do you have the drawing code here? I wonder if you can provide it. Thank you very much!

ayesha1093 commented 6 months ago

Hello, were you able to get the code right? Please share if you have it.

willleeney commented 4 months ago

I wrote some basic plotting code just to test the univariate forecasting on the electricity dataset. In tasks.eval_forecastings

I had to change line 72 onwards in forecasting...


test_pred_inv = scaler.inverse_transform(test_pred.squeeze((0,3)))
test_labels_inv = scaler.inverse_transform(test_labels.squeeze((0,3)))

import matplotlib.pyplot as plt 
plt.plot(data[:, :, n_covariate_cols:].squeeze((0, 2)), c='blue')
test_x_idxs = list(range(test_slice.start, data.shape[1]))
test_start_idx = 0
test_futures = lr.predict(test_repr.squeeze(0))[test_start_idx]
plt.plot(test_x_idxs[test_start_idx:len(test_futures)+test_start_idx], test_futures, c='red')
plt.show()

Unfortunately, it seems like the prediction is not very accurate or I have coded up the plotting wrong. If @zhihanyue could provide some insight into what I might have done wrong that would be great. As far as I understand it, the ridge regression predictions return a prediction for the next prediction_len timesteps so what I have done should plot the next prediction_len timestamps from the first test time stamp t.

Screenshot 2024-07-02 at 12 28 41