This component enriches calendar dates with additional context, ie working days and non working days are identified. Such variables can help to enhance time-series forecasts in SAP Predictive Analytics, Automated Analytics mode.

Depending on your use case, there might be many further date-related variables that could help improve a time-series forecast.

Disclaimer

Please note that this component is not an official release by SAP and that it is provided as-is without any guarantee or support. Please test the component to ensure it works for your purposes.

Prerequisites

  • R libraries lubridate, Hmisc and timeDate must be installed.
  • One column of type Text must contain the date.

Limitations

The component is not optimised for performance. For datasets in which the same date occurs multiple times you may want to restrict the data to unique dates first, add the date attributes and join these to the whole dataset.

Usage

These parameters can be set by the user:

Parameter Description
Date Column that contains the date in textual format.
Date Format

Specifies the string column’s date format in R notation. For instance: %d.%m.%Y

See the documentation of the as.Date() function for the syntax.

Holiday Reference

Specifies the region for identifying working days. Possible values are “London”, “New York Stock Exchange”, “Toronto Stock Exchange” and “Zurich”.

Output column added by this component:

Column Description
SundayMonthInd

Indicates if the date is a Sunday with the weekday’s occurrence count in the month so far. 0 otherwise.

MondayMonthInd Indicates if the date is a Monday with the weekday’s occurrence count in the month so far. 0 otherwise.
TuesdayMonthInd Indicates if the date is a Tuesday with the weekday’s occurrence count in the month so far. 0 otherwise.
WednesdayMonthInd Indicates if the date is a Wednesday with the weekday’s occurrence count in the month so far. 0 otherwise.
ThursdayMonthInd Indicates if the date is a Thursday with the weekday’s occurrence count in the month so far. 0 otherwise.
FridayMonthInd Indicates if the date is a Friday with the weekday’s occurrence count in the month so far. 0 otherwise.
SaturdayMonthInd Indicates if the date is a Saturday with the weekday’s occurrence count in the month so far. 0 otherwise.
LastSunday 1 if last Sunday of the month. 0 otherwise.
LastMonday 1 if last Monday of the month. 0 otherwise.
LastTuesday 1 if last Tuesday of the month. 0 otherwise.
LastWednesday 1 if last Wednesday of the month. 0 otherwise.
LastThursday 1 if last Thursday of the month. 0 otherwise.
LastFriday 1 if last Friday of the month. 0 otherwise.
LastSaturday 1 if last Saturday of the month. 0 otherwise.
PenultimateSunday 1 if penultimate Sunday of the month. 0 otherwise.
PenultimateMonday 1 if penultimate Monday of the month. 0 otherwise.
PenultimateTuesday 1 if penultimate Tuesday of the month. 0 otherwise.
PenultimateWednesday 1 if penultimate Wednesday of the month. 0 otherwise.
PenultimateThursday 1 if penultimate Thursday of the month. 0 otherwise.
PenultimateFriday 1 if penultimate Friday of the month. 0 otherwise.
PenultimateSaturday 1 if penultimate Saturday of the month. 0 otherwise.
Workingday 1 if working day (Saturday, Sunday, Bank Holiday). 0 otherwise.
BeforeHoliday 1 if before holiday. 0 otherwise.
Holiday 1 if holiday (Saturday, Sunday, Bank Holiday). 0 otherwise.
ContributionToWorkingMonth If working day: 1 divided by number of month’s working days. 0 otherwise.
ContributionToMonth 1 divided by number of month’s days.
MonthWorkingDayInd Indicates if working day with the work day’s occurrence count in the month so far. 0 otherwise.
ReverseMonthWorkingDayInd Indicates if working day by counting down the work day’s occurrence count in the month. 0 otherwise.
Last5WDinMonthInd Indicates the month’s last 5 working days by counting them up from 1 to 5. 0 otherwise.
Last5WDinMonth 1 if one the month’s last 5 working days. 0 otherwise.
Last4WDinMonthInd Indicates the month’s last 4 working days by counting them up from 1 to 4. 0 otherwise.
Last4WDinMonth 1 if one the month’s last 5 working days. 0 otherwise.

How to Implement

The component can be downloaded as .spar file from GitHub. Then deploy it as described here. You just need to import it through the option “Import/Model Component”, which you will find by clicking on the plus-sign at the bottom of the list of the available algorithms.

Example

This component was used to create some of the variables in the tutorial that forecasts the daily demand of the London bicycle hire scheme.

AddDateAttributes.PNG

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply