Working on Adding Seasonal Adjustment to Code
For most of the day I've been working on taking the fixed demand from a source and making it a year-long demand time series. It's not done, but it's close, and I've been testing the code along the way. The idea is pretty simple: the source of demand we're forced to work with is a single value given to us over a specific valid time window. That's it:
{ 'start_date': '2012-12-07', 'end_date': '2013-02-07', 'units': 1000, 'service': 'Skiing' }
of course there are locational components and taxonomy is a little more complicated than I've made it out to be, but for what we're doing, it doesn't matter.
On top of this, we have a source of Seasonality Factors that we have been given by the city planners and regional VPs. These are how they see the demand changing over the course of a year for a given service:
{ 'cleveland': { 'Skiing': [200 150 0 0 0 0 0 0 100 100 150 200], 'Ziplining': [0 0 100 100 100 100 150 150 150 150 100 50] } }
Here, we have two services for Cleveland - Skiing and Ziplining. The data shows that the factors (an array of integers representing the 12 months in the year) are high for Skiing in the cold months, and opposite that for Ziplining. Not a big surprise.
What I needed to get done today - and almost made it, was to take these factors and the raw demand and make a function that converted the initial demand data to something like this:
{ 'start_date': '2012-12-07', 'end_date': '2013-02-07', 'units': [2000 1500 0 0 0 0 0 0 1000 1000 1500 2000], 'service': 'Skiing' }
where the fixed 1000 units are multiplied by the factors (given in percentage) and expanded into a nice array. Interesting to note - we've got to do one more thing: when we have calculated the data like this, we need to rotate the time series of units to make sure that the current month is in the first position and the remaining 11 are in "the future" representing the next 11 months of demand.
It's this last part that got me today. I couldn't get it figured out. But I will.