Test and Convert non-stationary time-series to stationary
Project description
📊 StationarityToolkit
StationarityToolkit is a Python library designed to help you analyze and transform time series data for stationarity. It offers a suite of statistical tests and automated transformations to detect and handle both trend and variance non-stationarity.
Whether you're building a forecasting model or preparing data for analysis, this toolkit makes your preprocessing easier and more reliable.
🚀 Features
✅ 1. Test for Variance Non-Stationarity
- Use the Phillips-Perron test to detect variance instability.
✅ 2. Test for Trend Non-Stationarity
- Use both ADF (Augmented Dickey-Fuller) and KPSS (Kwiatkowski-Phillips-Schmidt-Shin) tests to check for trend-based non-stationarity.
🔧 3. Remove Trend Non-Stationarity
- Automatically apply:
- Trend differencing
- Seasonal differencing
- Or a combination of both
- Optimized for weekly seasonal data.
🔧 4. Remove Variance Non-Stationarity
- Automatically apply transformations like:
- Logarithmic
- Square root
- Box-Cox
- Selects the best transformation based on statistical significance.
- Skips transformation if variance is already stationary.
🧹 5. Remove All Non-Stationarity
- Combine both variance and trend removal in one pipeline:
- Detect and remove variance issues first
- Then proceed to handle trend non-stationarity
🛠️ Installation
pip install StationarityToolkit
🧪 Quick Start:
- Import the toolkit:
from stationarity_toolkit.stationarity_toolkit import StationarityToolkit
- Initialize the Toolkit:
toolkit = StationarityToolkit(alpha=0.05)
⚙️ Usage Guide
- ✅ Test for Stationarity:
toolkit.perform_pp_test(ts) # Phillips-Perron test for variance non-stationarity toolkit.adf_test(ts) # Augmented Dickey-Fuller test for trend toolkit.kpss_test(ts) # KPSS test for trend
- 🔧 Remove Variance Non-Stationarity
toolkit.remove_var_nonstationarity(ts_as_a_dataframe)
- Checks if variance non-stationarity exists.
- Applies log, square root, and Box-Cox transformations.
- Selects the transformation that produces the lowest p-value.
- Skips transformation if unnecessary.
- 🔧 Remove Trend Non-Stationarity
toolkit.remove_var_nonstationarity(ts_as_a_dataframe)
- Applies differencing techniques:
- Lag differencing
- Seasonal differencing
- Combination of both
- Evaluates each using ADF and KPSS tests to find the best transformation.
- ⚠️ Currently supports weekly seasonality only.
- 🧹 Remove All Non-Stationarity
toolkit.remove_nonstationarity(ts_as_a_dataframe)
- Runs both variance and trend checks/removal:
- Removes variance non-stationarity (if present)
- Then removes trend non-stationarity
💡 Why Stationarity Matters
- Most classical and deep learning time series models (ARIMA, VAR, Prophet, LSTM) assume that the data is stationary. Non-stationary data can lead to:
- Spurious regressions
- Poor model accuracy
- Invalid statistical inferences
StationarityToolkit helps you automate this critical preprocessing step with minimal manual intervention.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stationaritytoolkit-0.1.0.tar.gz.
File metadata
- Download URL: stationaritytoolkit-0.1.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08fb2ca5d35ddcaaa563bcce311151af6296e28c3bf01051deef1e5803c16790
|
|
| MD5 |
19d281efb1fdf7c579a78c20390ef16e
|
|
| BLAKE2b-256 |
7cd082cc7298a66572abad7e7e4552c17944ff73763565c98b85e41d8eadb659
|
File details
Details for the file stationaritytoolkit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: stationaritytoolkit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93387c8d9deddc4d162bea84a807dd0be77ae79c24f0b88b0eb2b88766a4ed81
|
|
| MD5 |
8a89d257c899a7369a4f4b7275e70f9d
|
|
| BLAKE2b-256 |
708f1d29c0c0bd02c0073d36390d26fabf8144e15a458cc7e2c6c20ad7a7b2a9
|