Smart, automatic detection and stationarization of non-stationary time series data.
>>> from stationarizer import simple_auto_stationarize
>>> simple_auto_stationarize(my_dataframe)
Contents
pip install stationarizer
- Plays nice with
pandas.DataFrame
inputs. - Pure python.
- Supports Python 3.6+.
The only stationarization pipeline implemented is simple_auto_stationarize
, which can be called with:
>>> from stationarizer import simple_auto_stationarize
>>> stationarized_df = simple_auto_stationarize(my_dataframe)
The level to which false discovery rate (FDR) is controled can be configured with the alpha
parameter, while the method for multitest error control can be configured with multitest
(changing this can change alpha
to control for FWER instead).
Currently only the following simple flow - dealing with unit roots - is implemented:
- Data validation is performed: all columns are checked to be numeric, and the time dimension is assumed to be larger than the number of series (although this is not mandatory, and so only a warning is thrown in case of violation).
- Both the Augmented Dickey-Fuller unit root test and the KPSS test are performed for each of the series.
- The p-values of all tests are corrected to control the false discovery rate (FDR) at some given level, using the Benjamini–Yekutieli procedure.
- The joint ADF-KPSS results are interpreted for each test (see image below).
- For each time series for which the presence of a unit root cannot be rejected, the series is diffentiated.
- For each time series for which the presence of a trend cannot be rejected, the series is de-trended.
- If any series was diffrentiated, then any un-diffrentiated time series (if any) are trimmed by one step to match the resulting series length.
Here is how joint ADF-KPSS results are interpreted, per-series:
Package author and current maintainer is Shay Palachy (shay.palachy@gmail.com); You are more than welcome to approach him for help. Contributions are very welcomed.
Clone:
git clone git@github.com:shaypal5/stationarizer.git
Install in development mode, including test dependencies:
cd stationarizer
pip install -e '.[test]'
To also install fasttext
, see instructions in the Installation section.
To run the tests use:
cd stationarizer
pytest
The project is documented using the numpy docstring conventions, which were chosen as they are perhaps the most widely-spread conventions that are both supported by common tools such as Sphinx and result in human-readable docstrings. When documenting code you add to this project, follow these conventions.
Additionally, if you update this README.rst
file, use python setup.py checkdocs
to validate it compiles.
Created by Shay Palachy (shay.palachy@gmail.com).