For time series analysis, everyone’s talking about ARIMA or Holt-Winters. But there’s other models which could also break down a seasonal series into trend, seasonality and noise. We will use an open source Python library called Seasonal to analyse B2B worldwide travel data.
2. Cheuk Tink Ho
@cheukting_ho
Data scientist at
Contributor ofMember of
Organizer of
● Base in London
● Love Python
● Love Comedy
● Love Beer & Cheese
● Love Travel
3.
4. Time Series:
- Sequential data: order matters
- Upsample, Downsample: by day, by week,
by month
- Pandas Datatime index
@pydataamsterdam
@cheukting_ho
5. Seasonal Data:
- Repeating pattern
- Cycle could be week, month or day
- Compare data at the same point in the
cycle
@pydataamsterdam
@cheukting_ho
6. Example -
AirPassenger Dataset
The number of passengers shows a
pattern of:
- Trend
- Seasonality
- Noise
Across time
@cheukting_ho
@pydataamsterdam
7. What can we do to
combat seasonality in
travel data?
8. Wholesale in Travel
- Clients may be closed for business
during public holidays
- Sales are different weekday / weekend
(seasonal)
- Business worldwide
- Estimate impact from public holiday
worldwide
@cheukting_ho
@pydataamsterdam
9. Workflow:
➔ Break data in different countries, for
each country:
➔ De-seasonal and de-trend the time
series
➔ Find the residual that goes beyond
the LCL (for holiday CY) / UCL (for
holiday LY)
➔ Match holidays in the country form
calendar to the residual
➔ Calculate impact (residual - LCL)
@cheukting_ho
@pydataamsterdam
10. Python library - seasonal
- Linear trend fitting with periodic data can be hazardous
- Apply a filter to knock down variations at the maximum expected period
- Seasonal offsets (same as Holt-Winters) for a given periodicity are
estimated as period-over-period averages using all the provided data
- Estimating the period using a time-domain approach that accommodates
any periodic signal shape
- Drawback: computationally expensive (O(n^2))
https://github.com/welch/seasonal
@pydataamsterdam
@cheukting_ho
12. Google Calendar API
Allows us to scrap all holiday in all countries as a
record, LY and CY holidays are compare on the
same weekday.
@pydataamsterdam
@cheukting_ho