From 425fc818eead2ade3a8cb9dd88e7a0b45e33011e Mon Sep 17 00:00:00 2001 From: Wenjie Du Date: Tue, 29 Nov 2022 14:20:11 +0800 Subject: [PATCH 1/5] feat: enable auto reply on PRs created by new contributors; --- .github/workflows/greetings.yml | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index 54c305d7..792ade46 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -1,6 +1,11 @@ name: Autoreply to Issues Opened for PyPOTS -on: [issues] +on: + issues: + types: [opened] + pull_request: + branches: [main] + types: [opened] jobs: greeting: @@ -11,4 +16,25 @@ jobs: - uses: actions/first-interaction@v1 with: repo-token: ${{ secrets.ACCESS_TOKEN }} - issue-message: "Hi there,

Thank you so much for your attention to PyPOTS! If you find PyPOTS helpful to your work, please star⭐️ this repository. Your star is your recognition, which can help more people notice PyPOTS and grow PyPOTS community. It matters and is definitely a kind of contribution.

I have received your message and will respond ASAP. Thank you for your patience! πŸ˜ƒ

Best,
Wenjie" + issue-message: | + Hi there πŸ‘‹, + + Thank you so much for your attention to PyPOTS! If you find PyPOTS helpful to your work, please star⭐️ this repository. Your star is your recognition, which can help more people notice PyPOTS and grow PyPOTS community. It matters and is definitely a kind of contribution to the community. + + I have received your message and will respond ASAP. Thank you for your patience! πŸ˜ƒ + + Best, + Wenjie + + pr-message: | + Hi there πŸ‘‹, + + Thank you for your contribution to PyPOTS! + + If you are trying to fix a bug, please reference the issue number in the description or give your details about the bug. + If you are implementing a feature request, please check with the maintainers that the feature will be accepted first. + + Best, + Wenjie + + From 144c4bf8bd3663e6bc4146d5e6afeb3d13356835 Mon Sep 17 00:00:00 2001 From: Wenjie Du Date: Thu, 1 Dec 2022 12:09:57 +0800 Subject: [PATCH 2/5] feat: simplify requirements to speed up the installation process of PyPOTS; --- environment.yml | 3 --- pypots/classification/raindrop.py | 19 +++++++++++++------ pypots/tests/environment_test.yml | 1 - requirements.txt | 7 ++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/environment.yml b/environment.yml index b6f88f58..396b79b2 100644 --- a/environment.yml +++ b/environment.yml @@ -1,7 +1,6 @@ name: pypots channels: - pytorch - - pyg - conda-forge - nodefaults dependencies: @@ -14,8 +13,6 @@ dependencies: - conda-forge::tensorboard - conda-forge::pip - pytorch::pytorch==1.11.0 - - pyg::pyg==2.0.4 - pip: - - torchdiffeq - pycorruptor==0.0.4 - tsdb==0.0.7 diff --git a/pypots/classification/raindrop.py b/pypots/classification/raindrop.py index 9d2907d3..81915aa0 100644 --- a/pypots/classification/raindrop.py +++ b/pypots/classification/raindrop.py @@ -26,12 +26,19 @@ from torch.nn import init from torch.nn.parameter import Parameter from torch.utils.data import DataLoader -from torch_geometric.nn.conv import MessagePassing -from torch_geometric.nn.inits import glorot -from torch_geometric.typing import PairTensor, Adj, OptTensor -from torch_geometric.utils import softmax -from torch_scatter import scatter -from torch_sparse import SparseTensor + +try: + from torch_geometric.nn.conv import MessagePassing + from torch_geometric.nn.inits import glorot + from torch_geometric.typing import PairTensor, Adj, OptTensor + from torch_geometric.utils import softmax + from torch_scatter import scatter + from torch_sparse import SparseTensor +except ImportError: + print( + "torch_geometric is missing, " + "please install it with 'pip install torch_geometric' or 'conda install -c pyg pyg'" + ) from pypots.classification.base import BaseNNClassifier from pypots.data.dataset_for_grud import DatasetForGRUD diff --git a/pypots/tests/environment_test.yml b/pypots/tests/environment_test.yml index ed9921f3..44c3a21c 100644 --- a/pypots/tests/environment_test.yml +++ b/pypots/tests/environment_test.yml @@ -19,6 +19,5 @@ dependencies: - pytorch::pytorch==1.11.0 - pyg::pyg==2.0.4 - pip: - - torchdiffeq - pycorruptor==0.0.4 - tsdb==0.0.7 diff --git a/requirements.txt b/requirements.txt index 206e1805..65d608aa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,11 +2,8 @@ matplotlib numpy scikit_learn scipy -torch >= 1.10 -torch_sparse == 0.6.13 -torch_scatter -torch_geometric +torch == 1.11.0 tensorboard pandas pycorruptor -tsdb +tsdb \ No newline at end of file From 905ee650c3d907ffc75e7adefdcff1b4f32341c7 Mon Sep 17 00:00:00 2001 From: Wenjie Du Date: Fri, 2 Dec 2022 02:23:16 +0800 Subject: [PATCH 3/5] feat: remove torch_geometric from the setup file as well to speed up installation; --- setup.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 20cc6be4..f0ba6587 100644 --- a/setup.py +++ b/setup.py @@ -21,8 +21,10 @@ "neural networks", "machine learning", "deep learning", + "time-series analysis", "partially observed", - "time series", + "irregular sampled", + "incomplete time series", "missing data", "missing values", ], @@ -34,9 +36,9 @@ "scikit_learn", "scipy", "torch>=1.10", # torch_sparse v0.6.12 requires 1.9<=torch<1.10, v0.6.13 needs torch>=1.10 - "torch_sparse==0.6.13", - "torch_scatter", - "torch_geometric", + # "torch_sparse==0.6.13", + # "torch_scatter", + # "torch_geometric", "tensorboard", "pandas", "pycorruptor", From 3f119f8dca36be766068dce03ee1d42978614bf2 Mon Sep 17 00:00:00 2001 From: Wenjie Du Date: Sun, 4 Dec 2022 15:39:13 +0800 Subject: [PATCH 4/5] doc: update README to add the usage example; --- README.md | 50 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 010333a7..e45c85c2 100644 --- a/README.md +++ b/README.md @@ -56,18 +56,44 @@ Visit [TSDB](https://github.com/WenjieDu/TSDB) right now to know more about this Install the latest release from PyPI: > pip install pypots +
+Below is an example applying SAITS in PyPOTS to impute missing values in the dataset PhysioNet2012: + +``` python +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) +# 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(X) # 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(X) # 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) +``` +
+ ## ❖ Available Algorithms -| Task | Type | Algorithm | Year | Reference | -|-------------------------------|----------------|---------------------------------------------------------------------------|------|-----------| -| Imputation | Neural Network | SAITS: Self-Attention-based Imputation for Time Series | 2022 | [^1] | -| Imputation | Neural Network | Transformer | 2017 | [^2] [^1] | -| Imputation,
Classification | Neural Network | BRITS (Bidirectional Recurrent Imputation for Time Series) | 2018 | [^3] | -| Imputation | Naive | LOCF (Last Observation Carried Forward) | - | - | -| Classification | Neural Network | GRU-D | 2018 | [^4] | -| Classification | Neural Network | Raindrop | 2022 | [^5] | -| Clustering | Neural Network | CRLI (Clustering Representation Learning on Incomplete time-series data) | 2021 | [^6] | -| Clustering | Neural Network | VaDER (Variational Deep Embedding with Recurrence) | 2019 | [^7] | -| Forecasting | Probabilistic | BTTF (Bayesian Temporal Tensor Factorization) | 2021 | [^8] | +| Task | Type | Algorithm | Year | Reference | +|-------------------------------|----------------|--------------------------------------------------------------------------|------|-----------| +| Imputation | Neural Network | SAITS (Self-Attention-based Imputation for Time Series) | 2022 | [^1] | +| Imputation | Neural Network | Transformer | 2017 | [^2] [^1] | +| Imputation,
Classification | Neural Network | BRITS (Bidirectional Recurrent Imputation for Time Series) | 2018 | [^3] | +| Imputation | Naive | LOCF (Last Observation Carried Forward) | - | - | +| Classification | Neural Network | GRU-D | 2018 | [^4] | +| Classification | Neural Network | Raindrop | 2022 | [^5] | +| Clustering | Neural Network | CRLI (Clustering Representation Learning on Incomplete time-series data) | 2021 | [^6] | +| Clustering | Neural Network | VaDER (Variational Deep Embedding with Recurrence) | 2019 | [^7] | +| Forecasting | Probabilistic | BTTF (Bayesian Temporal Tensor Factorization) | 2021 | [^8] | ## ❖ Reference If you find PyPOTS is helpful to your research, please cite it as below and ⭐️star this repository to make others notice this work. πŸ€— @@ -89,7 +115,7 @@ or ## ❖ Attention πŸ‘€ The documentation and tutorials are under construction. And a short paper introducing PyPOTS is on the way! πŸš€ Stay tuned please! -‼️ PyPOTS is currently under developing. If you like it and look forward to its growth, please give PyPOTS a star and watch it to keep you posted on its progress and to let me know that its development is meaningful. If you have any feedback, or want to contribute ideas/suggestions or share time-series related algorithms/papers, please join PyPOTS community and chat on , or create an issue. If you have any additional questions or have interests in collaboration, please take a look at [my GitHub profile](https://github.com/WenjieDu) and feel free to contact me πŸ˜ƒ. +‼️ PyPOTS is currently under developing. If you like it and look forward to its growth, please give PyPOTS a star and watch it to keep you posted on its progress and to let me know that its development is meaningful. If you have any feedback, or want to contribute ideas/suggestions or share time-series related algorithms/papers, please join PyPOTS community and chat on , or create an issue. If you have any additional questions or have interests in collaboration, please take a look at [my GitHub profile](https://github.com/WenjieDu) and feel free to contact me 🀝. Thank you all for your attention! πŸ˜ƒ From c9955a20c1572f2347a7e541d9479d31447f6e70 Mon Sep 17 00:00:00 2001 From: Wenjie Du Date: Tue, 20 Dec 2022 21:00:07 +0800 Subject: [PATCH 5/5] feat: print all outputs during test with pytest; --- .github/workflows/testing.yml | 6 +++--- pypots/__version__.py | 2 +- pypots/classification/raindrop.py | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 998838a3..50c62fe1 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -44,9 +44,9 @@ jobs: run: | # run tests separately here due to Segmentation Fault in test_clustering when run all in # one command with `pytest` on MacOS. Bugs not catched, so this is a trade-off to avoid SF. - python -m pytest pypots/tests/test_clustering.py -n auto --cov=pypots - python -m pytest pypots/tests/test_classification.py -n auto --cov=pypots --cov-append - python -m pytest pypots/tests/test_imputation.py -n auto --cov=pypots --cov-append + python -m pytest -rA pypots/tests/test_classification.py -n auto --cov=pypots --cov-append + python -m pytest -rA pypots/tests/test_imputation.py -n auto --cov=pypots --cov-append + python -m pytest -rA pypots/tests/test_clustering.py -n auto --cov=pypots - name: Generate the LCOV report run: | diff --git a/pypots/__version__.py b/pypots/__version__.py index bc00b346..b4069ba5 100644 --- a/pypots/__version__.py +++ b/pypots/__version__.py @@ -21,4 +21,4 @@ # Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer. # 'X.Y.dev0' is the canonical version of 'X.Y.dev' -version = "0.0.8" +version = "0.0.9" diff --git a/pypots/classification/raindrop.py b/pypots/classification/raindrop.py index 81915aa0..1772c165 100644 --- a/pypots/classification/raindrop.py +++ b/pypots/classification/raindrop.py @@ -34,8 +34,9 @@ from torch_geometric.utils import softmax from torch_scatter import scatter from torch_sparse import SparseTensor -except ImportError: +except ImportError as e: print( + f"{e}\n" "torch_geometric is missing, " "please install it with 'pip install torch_geometric' or 'conda install -c pyg pyg'" )