0

I am new to time series and would appreciate help in this matter.

I have a time series with the following graph as a result of applying the plot_acf in Python. Given this, can it be inferred that this series can be predictable via Machine Learning algorithms? I have already tried LSTM and N-HiTS to predict and the MAE is very large compared to the MAE using a baseline algorithm (the baseline MAE is 20% of the MAE using the previously mentioned algorithms) Autocorrelation plot of the series

I am adding the data that originated this ACF plot, which corresponds to actual sales figures:

  • 324
  • 281
  • 691
  • 281
  • 410
  • 346
  • 86
  • 43
  • 389
  • 43
  • 194
  • 22
  • 0
  • 130
  • 65
  • 173
  • 86
  • 281
  • 0
  • 0
  • 65
  • 43
  • 86
  • 65
  • 0
  • 0
  • 130
  • 65
  • 130
  • 173
  • 151
  • 43
  • 0
  • 43
  • 173
  • 108
  • 173
  • 130
  • 65
  • 0
  • 0
  • 0
  • 86
  • 86
  • 0
  • 22
  • 22
  • 22
  • 22
  • 22
  • 43
  • 43
  • 22
  • 65
  • 130
  • 130
  • -86
  • 22
  • 173
  • 43
  • 86
  • 43
  • 86
  • 22
  • 65
  • 0
  • 43
  • 43
  • 0
  • 194
  • 0
  • 0
  • 108
  • 108
  • 130
  • 86
  • 86
  • 22
  • 43
  • 86
  • 22
  • 0
  • 0
  • 43
  • 86
  • 22
  • 86
  • 22
  • 0
  • 108
  • 0
  • 65
  • 108
  • 22
  • 86
  • 43
  • 65
  • 43
  • 0
  • 108
  • 86
  • 0
  • 22
  • 65
  • 151
  • 0
  • 43
  • 86
  • 151
  • 43
  • 43
  • 22
  • 108
  • 0
  • 108
  • 0
  • 43
  • 65
  • 43
  • 108
  • 86
  • 0
  • 151
  • 22
  • 0
  • 108
  • 65
  • 65
  • 22
  • 0
  • 43
  • 22
  • 22
  • 65
  • 43
  • 130
  • 151
  • 108
  • 0
  • 130
  • 151
  • 130
  • 65
  • 0
  • 130
  • 43
  • 0
  • 0
  • 22
  • 43
  • 0
  • 65
  • 108
  • 22
  • 65
  • 0
  • 130
  • 86
  • 86
  • 281
  • 216
  • 22
  • 173
  • 108
  • 173
  • 302
  • 410
  • 86
  • 65
  • 65
  • 22
  • 86
  • 22
  • 194
  • 86
  • 130
  • 86
  • 216
  • 108
  • 173
  • 432
  • 238
  • 151
  • 194
  • 194
  • 324
  • 22
  • 367
  • 324
  • 238
  • 367
  • 410
  • 216
  • 497
  • 259
  • 108
  • 281
  • 281
  • 216
  • 108
  • 259
  • 216
  • 130
  • 65
  • 173
  • 86
  • 65
  • 43
  • 43
  • 86
  • 130
  • 194
  • 108
  • 194
  • 238
  • 108
  • 22
  • 43
  • 65
  • 173
  • 86
  • 151
  • 151
  • 130
  • 22
  • 151
  • 86
  • 281
  • 86
  • 259
  • 65
  • 86
  • 173
  • 65
  • 259
  • 173
  • 108
  • 238
  • 130
  • 151
  • 259
  • 259
  • 151
  • 389
  • 65
  • 259
  • 173
  • 238
  • 108
  • 43
  • 65
  • 173
  • 65
  • 65
  • 216
  • 151
  • 302
  • 86
  • 259
  • 130
  • 86
  • 151
  • 65
  • 238
  • 43
  • 86
  • 130
  • 65
  • 130
  • 259
  • 22
  • 432
  • 173
  • 216
  • 108
  • 130
  • 410
  • 324
  • 86
  • 475
  • 130
  • 410
  • 86
  • 216
  • 151
  • 173
  • 85
  • 302
  • 173
  • 259
  • 281
  • 281
  • 86
  • 173
  • 216
  • 302
  • 22
  • 108
  • 43
  • 108
  • 389
  • 245
  • 43
  • 43
  • 216
  • 22
  • 151
  • 302
  • 259
  • 194
  • 346
  • 43
  • 302
  • 194
  • 151
  • 194
  • 173
  • 43
  • 43
  • 281
  • 367
  • 43
  • 367
  • 43
  • 0
  • 65
  • 86
  • 151
  • 108
  • 281
  • 130
  • 22
  • 86
  • 389
  • 324
  • 216
  • 346
  • 43
  • 216
  • 43
  • 130
  • 497
  • 65
  • 22
  • 43
  • 238
  • 324
  • 0
  • 65
  • 43
  • 86
  • 216
  • 238
  • 43
  • 108
  • 194
  • 108
  • 605
  • 302
  • 130
  • 281
  • 86
  • 86
  • 302
  • 173
  • 216
  • 194
  • 86
  • 259
  • 151
  • 389
  • 194
  • 454
  • 65
  • 130
  • 518
  • 216
  • 43
  • 302
  • 22
  • 151
  • 216
  • 65
  • 302
  • 389
  • 281
  • 410
  • 259
  • 238
  • 151
  • 216
  • 389
  • 194
  • 216
  • 130
  • 194
  • 108
  • 65
  • 475
  • 194
  • 216
  • 43
  • 86
  • 86
  • 130
  • 410
  • 324
  • 173
  • 65
  • 86
  • 151
  • 324
  • 475
  • 281
  • 454
  • 130
  • 259
  • 389
  • 216
  • 86
  • 216
  • 194
  • 130
  • 454
  • 194
  • 108
  • 108
  • 43
  • 86
  • 65
  • 238
  • 65
  • 108
  • 86
  • 65
  • 22
  • 108
  • 216
  • 65
  • 65
  • 346
  • 281
  • 86
  • 302
  • 151
  • 324
  • 194
  • 151
  • 151
  • 108
  • 43
  • 0
  • 0
  • 65
  • 324
  • 281
  • 151
  • 0
  • 0
  • 389
  • 302
  • 432
  • 540
  • 108
  • 346
  • 0
  • 194
  • 238
  • 259
  • 130
  • 238
  • 389
  • 238
  • 518
  • 86
  • 281
  • 0
  • 0
  • 108
  • 43
  • 0
  • 0
  • 0
  • 65
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0
  • 108
  • 194
  • 0
  • 216
  • 238
  • 22
  • 43
  • 259
  • 216
  • 22
  • 410
  • 238
  • 86
  • 151
  • 281
  • 259
  • 151
  • 173
  • 432
  • 43
  • 238
  • 65
  • 389
  • 43
  • 173
  • 324
  • 130
  • 367
  • 194
  • 86
  • 65
  • 65
  • 302
  • 367
  • 367
  • 130
  • 216
  • 454
  • 65
  • 0
  • 432
  • 108
  • 0
  • 216
  • 194
  • 108
  • 281
  • 259
  • 108
  • 259
  • 173
  • 238
  • 367
  • 324
  • 259
  • 324
  • 346
  • 346
  • 194
  • 259
  • 151
  • 151
  • 238
  • 65
  • 346
  • 130
  • 562
  • 43
  • 108
  • 173
  • 43
  • 151
  • 65
  • 151
  • 86
  • 43
  • 194
  • 86
  • 22
  • 0
  • 0
  • 65
  • 43
  • 151
  • 43
  • 108
  • 86
  • 0
  • 130
  • 65
  • 65
  • 108
  • 65
  • 22
  • 0
  • 86
  • 0
  • 130
  • 43
  • 108
  • 86
  • 43
  • 108
  • 238
  • 259
  • 324
  • 497
  • 324
  • 346
  • 389
  • 259
  • 324
  • 151
  • 302
  • 389
  • 216
  • 281
  • 216
  • 324
  • 216
  • 194
  • 259
  • 43
  • 108
  • 302
  • 151
  • 22
  • 389
  • 454
  • 194
  • 324
  • 734
  • 0
  • 108
  • 238
  • 22
  • 0
  • 432
  • 108
  • 43
  • 0
  • 22
  • 43
  • 346
  • 43
  • 65
  • 130
  • 86
  • 302
  • 238
  • 475
  • 216
  • 389
  • 281
  • 497
  • 302
  • 65
  • 475
  • 432
  • 259
  • 173
  • 108
  • 216
  • 43
  • 65
  • 173
  • 238
  • 108
  • 86
  • 173
  • 43
  • 173
  • 518
  • 151
  • 281
  • 238
  • 216
  • 151
  • 238
  • 86
  • 173
  • 108
  • 43
  • 108
  • 65
  • 0
  • 259
  • 216
  • 216
  • 22
  • 216
  • 281
  • 259
  • 238
  • 130
  • 86
  • 238
  • 216
  • 173
  • 216
  • 346
  • 648
  • 216
  • 43
  • 302
  • 302
  • 108
  • 259
  • 216
  • 216
  • 194
  • 173
  • 86
  • 194
  • 130
  • 259
  • 194
  • 86
  • 389
  • 65
  • 410

Do you recommend using other methods to determine the predictability of the time series?

Many thanks for the help provided.

295
  • 1
  • 4
    You have given us an ACF plot, but neither the original series, nor any information about what the series measures. – Stephan Kolassa Apr 25 '23 at 20:11
  • @StephanKolassa thank you for your quick feedback. I have added the information you mentioned. I hope it helps. – 295 Apr 26 '23 at 09:48
  • Are these daily, weekly, monthly sales, or on some other kind of granularity? Do you only have this single time series, or is this just one of many? – Stephan Kolassa Apr 26 '23 at 10:31
  • @StephanKolassa These are daily sales figures, which only happen on weekdays. On weekdays with no sales, zero appears. I only have this time series. If necessary I can try to obtain more datapoints, but this will take quite some effort with associated time. Thank you once again – 295 Apr 26 '23 at 12:03
  • OK, thanks. Are weekdays for you Monday through Friday, or Monday through Saturday? – Stephan Kolassa Apr 26 '23 at 13:26
  • @StephanKolassa, the weekdays are Monday through Friday – 295 Apr 26 '23 at 14:59
  • @StephanKolassa Thank you for your answer. I will read the links you provided. In the meanwhile, let me clarify that the low values in the beginning of the series, are due to the COVID period and are clearly understood. – 295 Apr 26 '23 at 15:47
  • Very good. Then you might be able to improve your forecasts by either removing these data points (i.e., starting the time series later), or using a predictor and running a regression with time series errors. – Stephan Kolassa Apr 26 '23 at 16:10
  • @StephanKolassa Thanks for all your help – 295 Apr 26 '23 at 16:41
  • In the name of readability, it would be great if you can edit your question to include the data in a more succinct format and at the end of the question. Perhaps something similar to how StephanKolassa included the data in his answer? – dipetkov Apr 26 '23 at 17:27

1 Answers1

1

Your time series does not show any intra-week seasonality (see the seasonplot at the right below). Exponential Smoothing (as per ets() in the forecast package for R) chooses a model with no seasonality, additive errors and an additive trend with strong dampening, so the forecasts are almost flat. Since there is very little time series structure in your data, the prediction intervals are very wide (and actually go below zero, which probably does not make a lot of sense for your data).

Your series does show a number of prolonged periods of low sales. It may be worthwhile figuring out what happened during these times. I believe this has a better chance of improving your forecasts than tweaking the models: How to know that your machine learning problem is hopeless?.

In any case, you have far too little data for a ML method like LSTM to make much of a difference compared to standard time series methods. I recommend the resources here to learn more about forecasting: Resources/books for project on forecasting models

enter image description here

R code:

sales <- c(324L, 281L, 691L, 281L, 410L, 346L, 86L, 43L, 389L, 43L, 194L, 
22L, 0L, 130L, 65L, 173L, 86L, 281L, 0L, 0L, 65L, 43L, 86L, 65L, 
0L, 0L, 130L, 65L, 130L, 173L, 151L, 43L, 0L, 43L, 173L, 108L, 
173L, 130L, 65L, 0L, 0L, 0L, 86L, 86L, 0L, 22L, 22L, 22L, 22L, 
22L, 43L, 43L, 22L, 65L, 130L, 130L, -86L, 22L, 173L, 43L, 86L, 
43L, 86L, 22L, 65L, 0L, 43L, 43L, 0L, 194L, 0L, 0L, 108L, 108L, 
130L, 86L, 86L, 22L, 43L, 86L, 22L, 0L, 0L, 43L, 86L, 22L, 86L, 
22L, 0L, 108L, 0L, 65L, 108L, 22L, 86L, 43L, 65L, 43L, 0L, 108L, 
86L, 0L, 22L, 65L, 151L, 0L, 43L, 86L, 151L, 43L, 43L, 22L, 108L, 
0L, 108L, 0L, 43L, 65L, 43L, 108L, 86L, 0L, 151L, 22L, 0L, 108L, 
65L, 65L, 22L, 0L, 43L, 22L, 22L, 65L, 43L, 130L, 151L, 108L, 
0L, 130L, 151L, 130L, 65L, 0L, 130L, 43L, 0L, 0L, 22L, 43L, 0L, 
65L, 108L, 22L, 65L, 0L, 130L, 86L, 86L, 281L, 216L, 22L, 173L, 
108L, 173L, 302L, 410L, 86L, 65L, 65L, 22L, 86L, 22L, 194L, 86L, 
130L, 86L, 216L, 108L, 173L, 432L, 238L, 151L, 194L, 194L, 324L, 
22L, 367L, 324L, 238L, 367L, 410L, 216L, 497L, 259L, 108L, 281L, 
281L, 216L, 108L, 259L, 216L, 130L, 65L, 173L, 86L, 65L, 43L, 
43L, 86L, 130L, 194L, 108L, 194L, 238L, 108L, 22L, 43L, 65L, 
173L, 86L, 151L, 151L, 130L, 22L, 151L, 86L, 281L, 86L, 259L, 
65L, 86L, 173L, 65L, 259L, 173L, 108L, 238L, 130L, 151L, 259L, 
259L, 151L, 389L, 65L, 259L, 173L, 238L, 108L, 43L, 65L, 173L, 
65L, 65L, 216L, 151L, 302L, 86L, 259L, 130L, 86L, 151L, 65L, 
238L, 43L, 86L, 130L, 65L, 130L, 259L, 22L, 432L, 173L, 216L, 
108L, 130L, 410L, 324L, 86L, 475L, 130L, 410L, 86L, 216L, 151L, 
173L, 85L, 302L, 173L, 259L, 281L, 281L, 86L, 173L, 216L, 302L, 
22L, 108L, 43L, 108L, 389L, 245L, 43L, 43L, 216L, 22L, 151L, 
302L, 259L, 194L, 346L, 43L, 302L, 194L, 151L, 194L, 173L, 43L, 
43L, 281L, 367L, 43L, 367L, 43L, 0L, 65L, 86L, 151L, 108L, 281L, 
130L, 22L, 86L, 389L, 324L, 216L, 346L, 43L, 216L, 43L, 130L, 
497L, 65L, 22L, 43L, 238L, 324L, 0L, 65L, 43L, 86L, 216L, 238L, 
43L, 108L, 194L, 108L, 605L, 302L, 130L, 281L, 86L, 86L, 302L, 
173L, 216L, 194L, 86L, 259L, 151L, 389L, 194L, 454L, 65L, 130L, 
518L, 216L, 43L, 302L, 22L, 151L, 216L, 65L, 302L, 389L, 281L, 
410L, 259L, 238L, 151L, 216L, 389L, 194L, 216L, 130L, 194L, 108L, 
65L, 475L, 194L, 216L, 43L, 86L, 86L, 130L, 410L, 324L, 173L, 
65L, 86L, 151L, 324L, 475L, 281L, 454L, 130L, 259L, 389L, 216L, 
86L, 216L, 194L, 130L, 454L, 194L, 108L, 108L, 43L, 86L, 65L, 
238L, 65L, 108L, 86L, 65L, 22L, 108L, 216L, 65L, 65L, 346L, 281L, 
86L, 302L, 151L, 324L, 194L, 151L, 151L, 108L, 43L, 0L, 0L, 65L, 
324L, 281L, 151L, 0L, 0L, 389L, 302L, 432L, 540L, 108L, 346L, 
0L, 194L, 238L, 259L, 130L, 238L, 389L, 238L, 518L, 86L, 281L, 
0L, 0L, 108L, 43L, 0L, 0L, 0L, 65L, 0L, 0L, 0L, 0L, 0L, 0L, 108L, 
194L, 0L, 216L, 238L, 22L, 43L, 259L, 216L, 22L, 410L, 238L, 
86L, 151L, 281L, 259L, 151L, 173L, 432L, 43L, 238L, 65L, 389L, 
43L, 173L, 324L, 130L, 367L, 194L, 86L, 65L, 65L, 302L, 367L, 
367L, 130L, 216L, 454L, 65L, 0L, 432L, 108L, 0L, 216L, 194L, 
108L, 281L, 259L, 108L, 259L, 173L, 238L, 367L, 324L, 259L, 324L, 
346L, 346L, 194L, 259L, 151L, 151L, 238L, 65L, 346L, 130L, 562L, 
43L, 108L, 173L, 43L, 151L, 65L, 151L, 86L, 43L, 194L, 86L, 22L, 
0L, 0L, 65L, 43L, 151L, 43L, 108L, 86L, 0L, 130L, 65L, 65L, 108L, 
65L, 22L, 0L, 86L, 0L, 130L, 43L, 108L, 86L, 43L, 108L, 238L, 
259L, 324L, 497L, 324L, 346L, 389L, 259L, 324L, 151L, 302L, 389L, 
216L, 281L, 216L, 324L, 216L, 194L, 259L, 43L, 108L, 302L, 151L, 
22L, 389L, 454L, 194L, 324L, 734L, 0L, 108L, 238L, 22L, 0L, 432L, 
108L, 43L, 0L, 22L, 43L, 346L, 43L, 65L, 130L, 86L, 302L, 238L, 
475L, 216L, 389L, 281L, 497L, 302L, 65L, 475L, 432L, 259L, 173L, 
108L, 216L, 43L, 65L, 173L, 238L, 108L, 86L, 173L, 43L, 173L, 
518L, 151L, 281L, 238L, 216L, 151L, 238L, 86L, 173L, 108L, 43L, 
108L, 65L, 0L, 259L, 216L, 216L, 22L, 216L, 281L, 259L, 238L, 
130L, 86L, 238L, 216L, 173L, 216L, 346L, 648L, 216L, 43L, 302L, 
302L, 108L, 259L, 216L, 216L, 194L, 173L, 86L, 194L, 130L, 259L, 
194L, 86L, 389L, 65L, 410L)

sales_ts <- ts(sales,frequency=5)

library(forecast)

par(mfrow=c(1,2),las=1) model <- ets(sales_ts) plot(forecast(model,h=20)) seasonplot(ts(sales,frequency=5),pch=19)

Stephan Kolassa
  • 123,354