This repository contains python (3.5.2) implementation of RobustSTL (paper) .
Decomposing complex time series into trend, seasonality, and remainder components is an important task to facilitate time series anomaly detection and forecasting.
RobustSTL extract trend using LAD loss with sparse regularization and non-local seasonal filtering.
Compared to previous approaches (such as traditional STL), RobustSTL has advantages on
1) Ability to handle seasonality fluctuation and shift, and abrupt change in trend and reminder
2) robustness of data with anomalies
3) applicability on time series with long seasonality period.
First, install some required libraries using pip.
pip3 install -r requirments.txt
python3 main.py
We generate a synthetic sample (sample_generator.py) and decompose it into trend
, seasonality
, and remainder
.
In run_example.ipynb
, I attach the example codes to use RobustSTL and the outputs.
main.py
: run example codeRobustSTL.py
: contains RobustSTL algorithm and each process.utils.py
: common utility functionssample_generator.py
: generation codes of synthetic sample.l1.py
: optimizer of l1 norm approximation (source: cvxopt)Basically, RobustSTL is for univariate time series sample.
However, this codes are available on multi-variate time series sample.
(It apply the algorithm to each series, using multiprocessing)
Each series have to have same time length.
[Time] or [Time,1]
[N, Time] or [N, Time, 1]
The original paper has wrong notation in seasonality extraction.
The difference is log