t-kalinowski / deep-learning-with-R-2nd-edition-code

Code from the book "Deep Learning with R, 2nd Edition"
https://blogs.rstudio.com/ai/posts/2022-05-31-deep-learning-with-r-2e/
54 stars 22 forks source link

The data preparation question #7

Open ggeeoorrgg opened 1 year ago

ggeeoorrgg commented 1 year ago

As stated in the book's Chapter 10 "...The exact formulation of the problem will be as follows: given data covering the previous five days and sampled once per hour, can we predict the temperature in 24 hours?.." With this in mind do we really need to subtract 1 in : delay <- sampling_rate * (sequence_length + 24 - 1)? (see row #108 Ch 10). I know, this code matches the book. But for this delay the 1st sample:

> full_df$`Date Time`[1]
[1] "2009-01-01 00:10:00 -01"

has such target:

> head(tail(full_df$`Date Time`, -delay),1)
[1] "2009-01-06 23:10:00 -01"

It is not exactly 24 hours for a prediction horizon. Without subtracting 1 things seem to look better:

delay <- sampling_rate * (sequence_length + 24)
head(tail(full_df$`Date Time`, -delay),1)
[1] "2009-01-07 00:10:00 -01"

So i can`t figure out the reason for subtracting of 1. Any thoughts?