C4_W1_Lab_2_forecasting question

Hi All,
I have question relate the Centered windows Smoothing in Statistical Forecasting on Synthetic Data Lab.

For Ex: To get the smooth data point at t=1000 (i.e. start of the validation set), it will average the measurements at t=995 to t=1005 .

Here is the code in lab:

Smooth the original series before adding the time differenced moving average

diff_moving_avg_plus_smooth_past = moving_average_forecast(series[split_time - 370:-359], 11) + diff_moving_avg

I know that we shift 365 so the split_time - 365, and due to the window_size is 11, so we need to increase 5 more, so it becomes split_time - 370, that’s make sense.

For the last: -359, due to shift 365, so at first it will be -365. But the window_size is 11, so we need to increase 5 more. It should be -360.
Why the code is -359 here?
Please explain more for this case.

Thanks in advance,
Dat

Im not sure about this but I think is because the list starts counting form the 0th element!

Hi Gent,
Thanks for the answer.
I think I can figure it out. Actually, it comes from the function:

moving_average_forecast(series, window_size)

It calculates the average for each pack of window_size items but exclude the last item of series. So to count enough items for output of moving_average_forecast. We need to increase one more position, that is why it would be -359, not -360.

Hope that helps,

2 Likes

I have a doubt regarding calculation of smooth_past_series.

I was calculating the past_series using SERIES[SPLIT_TIME-365:-365]
Now when I calculate smooth_past_series, with window size of 10 shouldn’t it be moving_average_forecast(SERIES[SPLIT_TIME-365:-365], 10) ?

Problem with this logic is I end up with only 351 elements after calculating moving_average and diff_moving_avg is 361. As result I wont be able to add smooth_past_Series and diff_moving_avg

With window size of 11, right answer seems to be moving_average_forecast(SERIES[SPLIT_TIME-370:-359], 11). I am not sure why 370 and 359? Can anyone explain why ?