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