Holiday Shift Algorithm

About:

To identify the best day of the week threshold for holidays across years to shift/not shift by -1 week by revenue contribution

Data:

Process:

Illustration - Shift algorithm:

For example, - If Christmas occurred on Saturday, Monday, and Sunday on years Y1, Y2 and Y3, then the day of the week across the years Y1, Y2 and Y3 are 7, 2 and 1 respectively - Sorted day of the week list is [1, 2, 7] - Record the total revenue by not shifting any of the years by -1 week - Iterate through each sorted day of the week - For 1: Shift all years with day of the week <= 1. In this case, only Y3 would be shifted by -1 week and the total revenue is recorded - For 2: Shift all years with day of the week <= 2. In this case, only Y2 and Y3 would be shifted by -1 week and the total revenue is recorded - For 7: Shift all years with day of the week <= 7. In this case, Y1, Y2 and Y3 would be shifted by -1 week and the total revenue is recorded

Shift example

Unit Test:

If lead/lag holidays are present in the holidays output data - For each exact holiday (Christmas_0, Superbowl_0, Labour_day_0, etc.) - Get the weeks where the holiday happened across years and compare the weeks with the original holidays data. The weeks in the output file should lie either lie in the same week or same week -1 from the original holidays - For each lag holiday (Christmas_-1, Superbowl_-1, Labour_day_-1, etc.) - Get the weeks where the lag holiday happened across years and compare the weeks with the original holidays data. The weeks in the output file should lie either lie in the same week -1 or same week -2 from the original holidays - For each lead holiday (Christmas_1, Superbowl_1, Labour_day_1, etc.) - Get the weeks where the lead holiday happened across years and compare the weeks with the original holidays data. The weeks in the output file should lie either lie in the same week or same week +1 from the original holidays

If lead/lag holidays are absent in the holidays output data - For each exact holiday (Christmas, Superbowl, Labour_day, etc.) - Get the weeks where the holiday happened across years and compare the weeks with the original holidays data. The weeks in the output file should lie either lie in the same week or same week -1 from the original holidays Refer the unit test logic table below

Unit test logic