A Python Toolbox for Data Mining on Partially-Observed Time Series
β¦Ώ Motivation
: Due to all kinds of reasons like failure of collection sensors, communication error, and unexpected malfunction, missing values are common to see in time series from the real-world environment. This makes partially-observed time series (POTS) a pervasive problem in open-world modeling and prevents advanced data analysis. Although this problem is important, the area of data mining on POTS still lacks a dedicated toolkit. PyPOTS is created to fill in this blank.
β¦Ώ Mission
: PyPOTS is born to become a handy toolbox that is going to make data mining on POTS easy rather than tedious, to help engineers and researchers focus more on the core problems in their hands rather than on how to deal with the missing parts in their data. PyPOTS will keep integrating classical and the latest state-of-the-art data mining algorithms for partially-observed multivariate time series. For sure, besides various algorithms, PyPOTS is going to have unified APIs together with detailed documentation and interactive examples across algorithms as tutorials.
To make various open-source time-series datasets readily available to our users, PyPOTS gets supported by project TSDB (Time-Series Data Base), a toolbox making loading time-series datasets super easy!
Visit TSDB right now to know more about this handy tool π ! It now supports a total of 119 open-source datasets.
PyPOTS now is available on βοΈ
Install it with conda install pypots
, you may need to specify the channel with option -c conda-forge
Install the latest release from PyPI:
pip install pypots
or install from the source code with the latest features not officially released in a version:
pip install https://github.com/WenjieDu/PyPOTS/archive/main.zip
Below is an example applying SAITS in PyPOTS to impute missing values in the dataset PhysioNet2012:
import numpy as np
from sklearn.preprocessing import StandardScaler
from pypots.data import load_specific_dataset, mcar, masked_fill
from pypots.imputation import SAITS
from pypots.utils.metrics import cal_mae
# Data preprocessing. Tedious, but PyPOTS can help. π€
data = load_specific_dataset('physionet_2012') # PyPOTS will automatically download and extract it.
X = data['X']
num_samples = len(X['RecordID'].unique())
X = X.drop('RecordID', axis = 1)
X = StandardScaler().fit_transform(X.to_numpy())
X = X.reshape(num_samples, 48, -1)
X_intact, X, missing_mask, indicating_mask = mcar(X, 0.1) # hold out 10% observed values as ground truth
X = masked_fill(X, 1 - missing_mask, np.nan)
dataset = {"X": X}
# Model training. This is PyPOTS showtime. πͺ
saits = SAITS(n_steps=48, n_features=37, n_layers=2, d_model=256, d_inner=128, n_head=4, d_k=64, d_v=64, dropout=0.1, epochs=10)
saits.fit(dataset) # train the model. Here I use the whole dataset as the training set, because ground truth is not visible to the model.
imputation = saits.impute(dataset) # impute the originally-missing values and artificially-missing values
mae = cal_mae(imputation, X_intact, indicating_mask) # calculate mean absolute error on the ground truth (artificially-missing values)
PyPOTS supports imputation, classification, clustering, and forecasting tasks on multivariate time series with missing values. The currently available algorithms of four tasks are cataloged in the following table with four partitions. The paper references are all listed at the bottom of this readme file. Please refer to them if you want more details.
Imputation |
π₯ | π₯ | π₯ |
---|---|---|---|
Type | Abbr. | Full name of the algorithm/model/paper | Year |
Neural Net | SAITS | Self-Attention-based Imputation for Time Series 1 | 2023 |
Neural Net | Transformer | Attention is All you Need 2; Self-Attention-based Imputation for Time Series 1; Note: proposed in 2, and re-implemented as an imputation model in 1. |
2017 |
Neural Net | BRITS | Bidirectional Recurrent Imputation for Time Series 3 | 2018 |
Naive | LOCF | Last Observation Carried Forward | - |
Classification |
π₯ | π₯ | π₯ |
Type | Abbr. | Full name of the algorithm/model/paper | Year |
Neural Net | BRITS | Bidirectional Recurrent Imputation for Time Series 3 | 2018 |
Neural Net | GRU-D | Recurrent Neural Networks for Multivariate Time Series with Missing Values 4 | 2018 |
Neural Net | Raindrop | Graph-Guided Network for Irregularly Sampled Multivariate Time Series 5 | 2022 |
Clustering |
π₯ | π₯ | π₯ |
Type | Abbr. | Full name of the algorithm/model/paper | Year |
Neural Net | CRLI | Clustering Representation Learning on Incomplete time-series data 6 | 2021 |
Neural Net | VaDER | Variational Deep Embedding with Recurrence 7 | 2019 |
Forecasting |
π₯ | π₯ | π₯ |
Type | Abbr. | Full name of the algorithm/model/paper | Year |
Probabilistic | BTTF | Bayesian Temporal Tensor Factorization 8 | 2021 |
We are pursuing to publish a short paper introducing PyPOTS in prestigious academic venues, e.g. JMLR (track for Machine Learning Open Source Software). Before that, PyPOTS is using its DOI from Zenodo for reference. If you use PyPOTS in your research, please cite it as below and πstar this repository to make others notice this work. π€
@misc{du2022PyPOTS,
author = {Wenjie Du},
title = {{PyPOTS: A Python Toolbox for Data Mining on Partially-Observed Time Series}},
year = {2022},
howpublished = {\url{https://github.com/wenjiedu/pypots}},
url = {\url{https://github.com/wenjiedu/pypots}},
doi = {10.5281/zenodo.6823221},
}
or
Wenjie Du. (2022). PyPOTS: A Python Toolbox for Data Mining on Partially-Observed Time Series. Zenodo. https://doi.org/10.5281/zenodo.6823221
You're very welcome to contribute to this exciting project!
By committing your code, you'll
- make your well-established model out-of-the-box for PyPOTS users to run;
- be listed as one of PyPOTS contributors: ;
- get mentioned in our release notes;
You can also contribute to PyPOTS by simply staringπ this repo to help more people notice it. Your star is your recognition to PyPOTS, and it matters!
π Click here to view PyPOTS stargazers and forkers.
We're so proud to have more and more awesome users, as well as more bright β¨stars:
The documentation and tutorials are under construction.
Thank you all for your attention! π
Footnotes
-
Du, W., Cote, D., & Liu, Y. (2023). SAITS: Self-Attention-based Imputation for Time Series. Expert systems with applications. β© β©2 β©3
-
Vaswani, A., Shazeer, N.M., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A.N., Kaiser, L., & Polosukhin, I. (2017). Attention is All you Need. NeurIPS 2017. β© β©2
-
Cao, W., Wang, D., Li, J., Zhou, H., Li, L., & Li, Y. (2018). BRITS: Bidirectional Recurrent Imputation for Time Series. NeurIPS 2018. β© β©2
-
Che, Z., Purushotham, S., Cho, K., Sontag, D.A., & Liu, Y. (2018). Recurrent Neural Networks for Multivariate Time Series with Missing Values. Scientific Reports. β©
-
Zhang, X., Zeman, M., Tsiligkaridis, T., & Zitnik, M. (2022). Graph-Guided Network for Irregularly Sampled Multivariate Time Series. ICLR 2022. β©
-
Ma, Q., Chen, C., Li, S., & Cottrell, G. W. (2021). Learning Representations for Incomplete Time Series Clustering. AAAI 2021. β©
-
Jong, J.D., Emon, M.A., Wu, P., Karki, R., Sood, M., Godard, P., Ahmad, A., Vrooman, H.A., Hofmann-Apitius, M., & FrΓΆhlich, H. (2019). Deep learning for clustering of multivariate clinical patient trajectories with missing values. GigaScience. β©
-
Chen, X., & Sun, L. (2021). Bayesian Temporal Factorization for Multidimensional Time Series Prediction. IEEE transactions on pattern analysis and machine intelligence. β©