PyPOTS - A Python Toolbox for Data Mining on Partially-Observed Time Series

Overview

Welcome to PyPOTS

A Python Toolbox for Data Mining on Partially-Observed Time Series

PyPI

⦿ 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 DataBase), a toolbox making loading time-series datasets super easy!

Visit TSDB right now to know more about this handy tool 🛠 !

❖ Installation

Install the latest release from PyPI:

pip install pypots

Install with the latest code on GitHub:

pip install https://github.com/WenjieDu/PyPOTS/archive/main.zip

❖ 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

‼️ 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 , or drop me an email.

Thank you all for your attention! 😃

Footnotes

  1. Du, W., Cote, D., & Liu, Y. (2022). SAITS: Self-Attention-based Imputation for Time Series. ArXiv, abs/2202.08516. 2

  2. 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.

  3. Cao, W., Wang, D., Li, J., Zhou, H., Li, L., & Li, Y. (2018). BRITS: Bidirectional Recurrent Imputation for Time Series. NeurIPS 2018.

  4. Che, Z., Purushotham, S., Cho, K., Sontag, D.A., & Liu, Y. (2018). Recurrent Neural Networks for Multivariate Time Series with Missing Values. Scientific Reports, 8.

  5. Zhang, X., Zeman, M., Tsiligkaridis, T., & Zitnik, M. (2022). Graph-Guided Network for Irregularly Sampled Multivariate Time Series. ICLR 2022.

  6. Ma, Q., Chen, C., Li, S., & Cottrell, G. W. (2021). Learning Representations for Incomplete Time Series Clustering. AAAI 2021.

  7. 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, 8.

  8. Sun, L., & Chen, X. (2021). Bayesian Temporal Factorization for Multidimensional Time Series Prediction. IEEE transactions on pattern analysis and machine intelligence, PP.

Comments
  • [Feature request] Is it possible to

    [Feature request] Is it possible to "warm-up" the transformer?

    Thank you for creating this wonderful resource! This is an amazing and useful tool!

    Regarding SAITS, is it possible to pass a learning rate scheduler, rather than a fixed learning rate, for the transformer to pre-train?

    I ask this because I compared the outputs of training 100 epochs vs 1000 epochs. The loss continues to decrease, but the error on holdout timepoints does not change between 100 vs 1000 epochs. Strangely, the prediction (after 100 & 1000 epochs) is less accurate than linear interpolation...! I wondered if it is because the transformers have too many parameters, and it needs some help learning initially.

    opened by b2jia 9
  • can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

    can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

    PS C:\Users\Lyc\Downloads\PyPOTS-main\PyPOTS-main> & C:/Users/Lyc/AppData/Local/Programs/Python/Python39/python.exe c:/Users/Lyc/Downloads/PyPOTS-main/PyPOTS-main/pypots/tests/test_imputation.py Running test cases for BRITS... Model initialized successfully. Number of the trainable parameters: 580976 epoch 0: training loss 1.2366, validating loss 0.4201 epoch 1: training loss 0.8974, validating loss 0.3540 epoch 2: training loss 0.7426, validating loss 0.2919 epoch 3: training loss 0.6147, validating loss 0.2414 epoch 4: training loss 0.5411, validating loss 0.2157 ERunning test cases for BRITS... Model initialized successfully. Number of the trainable parameters: 580976 epoch 0: training loss 1.2054, validating loss 0.4022 epoch 1: training loss 0.8631, validating loss 0.3399 epoch 2: training loss 0.7204, validating loss 0.2863 epoch 3: training loss 0.5995, validating loss 0.2399 epoch 4: training loss 0.5325, validating loss 0.2123 ERunning test cases for LOCF... LOCF test_MAE: 0.17510570872656786 .Running test cases for LOCF... .Running test cases for SAITS... Model initialized successfully. Number of the trainable parameters: 1332704 epoch 0: training loss 0.9181, validating loss 0.2936 epoch 1: training loss 0.6287, validating loss 0.2303 epoch 2: training loss 0.5345, validating loss 0.2086 epoch 3: training loss 0.4735, validating loss 0.1895 epoch 4: training loss 0.4224, validating loss 0.1744 ERunning test cases for SAITS... Model initialized successfully. Number of the trainable parameters: 1332704 epoch 0: training loss 0.7823, validating loss 0.2779 epoch 1: training loss 0.5015, validating loss 0.2250 epoch 2: training loss 0.4418, validating loss 0.2097 epoch 3: training loss 0.4119, validating loss 0.1994 epoch 4: training loss 0.3866, validating loss 0.1815 ERunning test cases for Transformer... Model initialized successfully. Number of the trainable parameters: 666122 epoch 0: training loss 0.7715, validating loss 0.2843 epoch 1: training loss 0.4861, validating loss 0.2271 epoch 2: training loss 0.4176, validating loss 0.2077 epoch 3: training loss 0.3822, validating loss 0.2005 epoch 4: training loss 0.3592, validating loss 0.1961 ERunning test cases for Transformer... Model initialized successfully. Number of the trainable parameters: 666122 epoch 0: training loss 0.8033, validating loss 0.2910 epoch 1: training loss 0.4856, validating loss 0.2345 epoch 2: training loss 0.4282, validating loss 0.2157 epoch 3: training loss 0.3882, validating loss 0.2051 epoch 4: training loss 0.3599, validating loss 0.1942 E

    ERROR: test_impute (main.TestBRITS)

    Traceback (most recent call last): File "c:\Users\Lyc\Downloads\PyPOTS-main\PyPOTS-main\pypots\tests\test_imputation.py", line 125, in setUp self.brits.fit(self.train_X, self.val_X) File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\pypots\imputation\brits.py", line 504, in fit self._train_model(training_loader, val_loader, val_X_intact, val_X_indicating_mask) File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\pypots\imputation\base.py", line 142, in _train_model if np.equal(self.best_loss, float('inf')): File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\torch_tensor.py", line 732, in array return self.numpy() TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

    ====================================================================== ERROR: test_parameters (main.TestBRITS)

    Traceback (most recent call last): File "c:\Users\Lyc\Downloads\PyPOTS-main\PyPOTS-main\pypots\tests\test_imputation.py", line 125, in setUp self.brits.fit(self.train_X, self.val_X) File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\pypots\imputation\brits.py", line 504, in fit self._train_model(training_loader, val_loader, val_X_intact, val_X_indicating_mask) File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\pypots\imputation\base.py", line 142, in _train_model if np.equal(self.best_loss, float('inf')): File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\torch_tensor.py", line 732, in array return self.numpy() TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

    ====================================================================== ERROR: test_impute (main.TestSAITS)

    Traceback (most recent call last): File "c:\Users\Lyc\Downloads\PyPOTS-main\PyPOTS-main\pypots\tests\test_imputation.py", line 45, in setUp self.saits.fit(self.train_X, self.val_X) File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\pypots\imputation\saits.py", line 170, in fit self._train_model(training_loader, val_loader, val_X_intact, val_X_indicating_mask) File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\pypots\imputation\base.py", line 142, in _train_model if np.equal(self.best_loss, float('inf')): File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\torch_tensor.py", line 732, in array return self.numpy() TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

    ====================================================================== ERROR: test_parameters (main.TestSAITS)

    Traceback (most recent call last): File "c:\Users\Lyc\Downloads\PyPOTS-main\PyPOTS-main\pypots\tests\test_imputation.py", line 45, in setUp self.saits.fit(self.train_X, self.val_X) File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\pypots\imputation\saits.py", line 170, in fit self._train_model(training_loader, val_loader, val_X_intact, val_X_indicating_mask) File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\pypots\imputation\base.py", line 142, in _train_model if np.equal(self.best_loss, float('inf')): File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\torch_tensor.py", line 732, in array return self.numpy() TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

    ====================================================================== ERROR: test_impute (main.TestTransformer)

    Traceback (most recent call last): File "c:\Users\Lyc\Downloads\PyPOTS-main\PyPOTS-main\pypots\tests\test_imputation.py", line 89, in setUp self.transformer.fit(self.train_X, self.val_X) File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\pypots\imputation\transformer.py", line 256, in fit self._train_model(training_loader, val_loader, val_X_intact, val_X_indicating_mask) File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\pypots\imputation\base.py", line 142, in _train_model if np.equal(self.best_loss, float('inf')): File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\torch_tensor.py", line 732, in array return self.numpy() TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

    ====================================================================== ERROR: test_parameters (main.TestTransformer)

    Traceback (most recent call last): File "c:\Users\Lyc\Downloads\PyPOTS-main\PyPOTS-main\pypots\tests\test_imputation.py", line 89, in setUp self.transformer.fit(self.train_X, self.val_X) File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\pypots\imputation\transformer.py", line 256, in fit self._train_model(training_loader, val_loader, val_X_intact, val_X_indicating_mask) File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\pypots\imputation\base.py", line 142, in _train_model if np.equal(self.best_loss, float('inf')): File "C:\Users\Lyc\AppData\Local\Programs\Python\Python39\lib\site-packages\torch_tensor.py", line 732, in array return self.numpy() TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.


    Ran 8 tests in 176.311s

    FAILED (errors=6)

    opened by BasinChen 8
  • BRITS imputation test fails on cuda device mismatch

    BRITS imputation test fails on cuda device mismatch

    Hi, when trying to run imputation tests with commit 6dcc8942459094e3a3fc5e11363f5d712ee8e742 on dev branch.

    py3.9_cuda11.3_cudnn8.2.0_0

    $ python -m pytest tests/test_imputation.py
    
    ./tests/test_imputation.py::TestBRITS::test_parameters Failed with Error: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
      File ".../unittest/case.py", line 59, in testPartExecutor
        yield
      File ".../unittest/case.py", line 588, in run
        self._callSetUp()
      File ".../unittest/case.py", line 547, in _callSetUp
        self.setUp()
      File ".../PyPOTS/pypots/tests/test_imputation.py", line 98, in setUp
        self.brits.fit(self.train_X, self.val_X)
      File "/PyPOTS/pypots/imputation/brits.py", line 504, in fit
        self._train_model(training_loader, val_loader, val_X_intact, val_X_indicating_mask)
      File "/PyPOTS/pypots/imputation/base.py", line 154, in _train_model
        if np.equal(self.best_loss, float("inf")):
      File .../lib/python3.9/site-packages/torch/_tensor.py", line 732, in __array__
        return self.numpy()
    TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
    
    opened by MaciejSkrabski 4
  • GPU enabled model raises Exception: expected self and mask to be on the same device, but got mask on cpu and self on cuda:0

    GPU enabled model raises Exception: expected self and mask to be on the same device, but got mask on cpu and self on cuda:0

    Hello, great library, but using gpu enabled machine results in errors.

    pypots version = 0.0.6 (the one available in PyPI)

    code to replicate problem:

    import unittest
    from pypots.tests.test_imputation import TestBRITS, TestLOCF, TestSAITS, TestTransformer
    from pypots import __version__
    
    
    if __name__ == "__main__":
        print(__version__)
        unittest.main()
    

    results:

    0.0.6
    Running test cases for BRITS...
    Model initialized successfully. Number of the trainable parameters: 580976
    ERunning test cases for BRITS...
    Model initialized successfully. Number of the trainable parameters: 580976
    ERunning test cases for LOCF...
    LOCF test_MAE: 0.1712224306027283
    .Running test cases for LOCF...
    .Running test cases for SAITS...
    Model initialized successfully. Number of the trainable parameters: 1332704
    Exception: expected self and mask to be on the same device, but got mask on cpu and self on cuda:0
    ERunning test cases for SAITS...
    Model initialized successfully. Number of the trainable parameters: 1332704
    Exception: expected self and mask to be on the same device, but got mask on cpu and self on cuda:0
    ERunning test cases for Transformer...
    Model initialized successfully. Number of the trainable parameters: 666122
    epoch 0: training loss 0.7681, validating loss 0.2941
    epoch 1: training loss 0.4731, validating loss 0.2395
    epoch 2: training loss 0.4235, validating loss 0.2069
    epoch 3: training loss 0.3781, validating loss 0.1914
    epoch 4: training loss 0.3530, validating loss 0.1837
    ERunning test cases for Transformer...
    Model initialized successfully. Number of the trainable parameters: 666122
    epoch 0: training loss 0.7826, validating loss 0.2820
    epoch 1: training loss 0.4687, validating loss 0.2352
    epoch 2: training loss 0.4188, validating loss 0.2132
    epoch 3: training loss 0.3857, validating loss 0.1977
    epoch 4: training loss 0.3604, validating loss 0.1945
    E
    ======================================================================
    ERROR: test_impute (pypots.tests.test_imputation.TestBRITS)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "mydirs(...)/python3.9/site-packages/pypots/tests/test_imputation.py", line 99, in setUp
        self.brits.fit(self.train_X, self.val_X)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/brits.py", line 494, in fit
        training_set = DatasetForBRITS(train_X)  # time_gaps is necessary for BRITS
      File "mydirs(...)/python3.9/site-packages/pypots/data/dataset_for_brits.py", line 62, in __init__
        forward_delta = parse_delta(forward_missing_mask)
      File "mydirs(...)/python3.9/site-packages/pypots/data/dataset_for_brits.py", line 36, in parse_delta
        delta.append(torch.ones(1, n_features) + (1 - m_mask[step]) * delta[-1])
    RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
    
    ======================================================================
    ERROR: test_parameters (pypots.tests.test_imputation.TestBRITS)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "mydirs(...)/python3.9/site-packages/pypots/tests/test_imputation.py", line 99, in setUp
        self.brits.fit(self.train_X, self.val_X)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/brits.py", line 494, in fit
        training_set = DatasetForBRITS(train_X)  # time_gaps is necessary for BRITS
      File "mydirs(...)/python3.9/site-packages/pypots/data/dataset_for_brits.py", line 62, in __init__
        forward_delta = parse_delta(forward_missing_mask)
      File "mydirs(...)/python3.9/site-packages/pypots/data/dataset_for_brits.py", line 36, in parse_delta
        delta.append(torch.ones(1, n_features) + (1 - m_mask[step]) * delta[-1])
    RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
    
    ======================================================================
    ERROR: test_impute (pypots.tests.test_imputation.TestSAITS)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/base.py", line 83, in _train_model
        results = self.model.forward(inputs)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/saits.py", line 95, in forward
        imputed_data, [X_tilde_1, X_tilde_2, X_tilde_3] = self.impute(inputs)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/saits.py", line 62, in impute
        enc_output, _ = encoder_layer(enc_output)
      File "mydirs(...)/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
        return forward_call(*input, **kwargs)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/transformer.py", line 122, in forward
        enc_output, attn_weights = self.slf_attn(enc_input, enc_input, enc_input, attn_mask=mask_time)
      File "mydirs(...)/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
        return forward_call(*input, **kwargs)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/transformer.py", line 72, in forward
        v, attn_weights = self.attention(q, k, v, attn_mask)
      File "mydirs(...)/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
        return forward_call(*input, **kwargs)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/transformer.py", line 32, in forward
        attn = attn.masked_fill(attn_mask == 1, -1e9)
    RuntimeError: expected self and mask to be on the same device, but got mask on cpu and self on cuda:0
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "mydirs(...)/python3.9/site-packages/pypots/tests/test_imputation.py", line 35, in setUp
        self.saits.fit(self.train_X, self.val_X)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/saits.py", line 171, in fit
        self._train_model(training_loader, val_loader, val_X_intact, val_X_indicating_mask)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/base.py", line 123, in _train_model
        raise RuntimeError('Training got interrupted. Model was not get trained. Please try fit() again.')
    RuntimeError: Training got interrupted. Model was not get trained. Please try fit() again.
    
    ======================================================================
    ERROR: test_parameters (pypots.tests.test_imputation.TestSAITS)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/base.py", line 83, in _train_model
        results = self.model.forward(inputs)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/saits.py", line 95, in forward
        imputed_data, [X_tilde_1, X_tilde_2, X_tilde_3] = self.impute(inputs)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/saits.py", line 62, in impute
        enc_output, _ = encoder_layer(enc_output)
      File "mydirs(...)/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
        return forward_call(*input, **kwargs)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/transformer.py", line 122, in forward
        enc_output, attn_weights = self.slf_attn(enc_input, enc_input, enc_input, attn_mask=mask_time)
      File "mydirs(...)/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
        return forward_call(*input, **kwargs)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/transformer.py", line 72, in forward
        v, attn_weights = self.attention(q, k, v, attn_mask)
      File "mydirs(...)/python3.9/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl
        return forward_call(*input, **kwargs)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/transformer.py", line 32, in forward
        attn = attn.masked_fill(attn_mask == 1, -1e9)
    RuntimeError: expected self and mask to be on the same device, but got mask on cpu and self on cuda:0
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "mydirs(...)/python3.9/site-packages/pypots/tests/test_imputation.py", line 35, in setUp
        self.saits.fit(self.train_X, self.val_X)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/saits.py", line 171, in fit
        self._train_model(training_loader, val_loader, val_X_intact, val_X_indicating_mask)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/base.py", line 123, in _train_model
        raise RuntimeError('Training got interrupted. Model was not get trained. Please try fit() again.')
    RuntimeError: Training got interrupted. Model was not get trained. Please try fit() again.
    
    ======================================================================
    ERROR: test_impute (pypots.tests.test_imputation.TestTransformer)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "mydirs(...)/python3.9/site-packages/pypots/tests/test_imputation.py", line 68, in setUp
        self.transformer.fit(self.train_X, self.val_X)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/transformer.py", line 257, in fit
        self._train_model(training_loader, val_loader, val_X_intact, val_X_indicating_mask)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/base.py", line 129, in _train_model
        if np.equal(self.best_loss, float('inf')):
      File "mydirs(...)/python3.9/site-packages/torch/_tensor.py", line 732, in __array__
        return self.numpy()
    TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
    
    ======================================================================
    ERROR: test_parameters (pypots.tests.test_imputation.TestTransformer)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "mydirs(...)/python3.9/site-packages/pypots/tests/test_imputation.py", line 68, in setUp
        self.transformer.fit(self.train_X, self.val_X)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/transformer.py", line 257, in fit
        self._train_model(training_loader, val_loader, val_X_intact, val_X_indicating_mask)
      File "mydirs(...)/python3.9/site-packages/pypots/imputation/base.py", line 129, in _train_model
        if np.equal(self.best_loss, float('inf')):
      File "mydirs(...)/python3.9/site-packages/torch/_tensor.py", line 732, in __array__
        return self.numpy()
    TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.
    
    ----------------------------------------------------------------------
    Ran 8 tests in 20.239s
    
    FAILED (errors=6)
    

    i suspect that you call .to(device) too early on data. You might also override device parameter when initiating new tensors (i.e. in torch.ones in parse_delta)

    Best regards!

    opened by MaciejSkrabski 4
  • Early stop

    Early stop

    Wenjie,

    I tried the PyPOTS with the Beijing Air quality database. For the dataset preparation, I follow the gene_UCI_BeijingAirQuality_dataset. The following is the PyPOTS setup.

    saits_base = SAITS(seq_len=seq_len, n_features=132, 
                       n_layers=2,  # num of group-inner layers
                       d_model=256, # model hidden dim
                       d_inner=128, # hidden size of feed forward layer
                       n_head=4, # head num of self-attention
                       d_k=64, d_v=64, # key dim, value dim
                       dropout=0, 
                       epochs=200,
                       patience=30,
                       batch_size=32,
                       weight_decay=1e-5,
                       ORT_weight=1,
                       MIT_weight=1,
                      )
    
    saits_base.fit(train_set_X)
    

    PyPOTS stops earlier than the epochs specified (stops around epoch 80), without triggering either print('Exceeded the training patience. Terminating the training procedure...') or print('Finished all training epochs.').

    epoch 0: training loss 0.9637 
    epoch 1: training loss 0.6161 
    epoch 2: training loss 0.5177 
    epoch 3: training loss 0.4783 
    epoch 4: training loss 0.4489 
    ...
    epoch 73: training loss 0.2462 
    epoch 74: training loss 0.2460 
    epoch 75: training loss 0.2480 
    epoch 76: training loss 0.2452 
    epoch 77: training loss 0.2452 
    epoch 78: training loss 0.2458 
    epoch 79: training loss 0.2449 
    epoch 80: training loss 0.2423 
    epoch 81: training loss 0.2425 
    epoch 82: training loss 0.2443 
    epoch 83: training loss 0.2403 
    epoch 84: training loss 0.2406
    
    

    Then I evaluate the model performance (not knowing why the model stops early) on test_set as

    test_set_mae = cal_mae(test_set_imputation, test_set_X_intact, test_set_indicating_mask)
    0.21866121846582318
    

    I have a few questions:

    1. What could be the cause for the early stop?
    2. In addition, is there any object in saits_base that stores the loss history?
    3. Does the function cal_mae calculate the same MAE in your paper? For this Beijing air quality case, I should be able to tune the hyperparameter to get the test_set_mae down to around 0.146?

    Thank you, Haochen

    opened by Rdfing 2
  • fix: brits on cuda

    fix: brits on cuda

    Some tensors created on the fly (mainly in base.py and dataset_for_brits.py ) used to ignore the model's and data's device (cpu or gpu). This caused BRITS to throw errors whenever users wanted to run it on cuda enabled machine.

    opened by MaciejSkrabski 1
  • Update and fix the dependencies in the development env

    Update and fix the dependencies in the development env

    As mentioned in #7, I am trying to update and fix the dependencies of the development environment for testing cases. Expecting this can help speed up the processing of setting up Conda when running tests.

    opened by WenjieDu 1
  • refactor: explicit channels in conda env ymls

    refactor: explicit channels in conda env ymls

    Hi! You may have noticed that, when creating a new conda environment from *.yml file, it takes ages to solve package dependencies. I attempt to speed the process up by explicitly defining channel in which to search for a package. I also defined minimal pandas version to be 1.4.1 - the things were weird before that. I also allow for python versions newer than 3.7.13 and I believe you'll find it acceptable.

    Please let me know if this is in any way helpful.

    opened by MaciejSkrabski 9
Releases(v0.0.9)
  • v0.0.9(Dec 20, 2022)

    In this version, we speed up the installation process of PyPOTS. We noticed that torch_geometric and related dependencies take too much time to install. Therefore, they're removed from the list of requirements. They're necessary for the graph model RainDrop. Hence, users who need RainDrop have to install torch_geometric manually after they set up PyPOTS.

    What's Changed

    • Merge updates by @WenjieDu in https://github.com/WenjieDu/PyPOTS/pull/23
    • Update README and add the configurations of docs by @WenjieDu in https://github.com/WenjieDu/PyPOTS/pull/24
    • Merge dev into main by @WenjieDu in https://github.com/WenjieDu/PyPOTS/pull/26
    • Merge dev into main by @WenjieDu in https://github.com/WenjieDu/PyPOTS/pull/28

    Full Changelog: https://github.com/WenjieDu/PyPOTS/compare/v0.0.8...v0.0.9

    Source code(tar.gz)
    Source code(zip)
  • v0.0.8(Sep 13, 2022)

    Fixed bugs with running on CUDA devices;

    What's Changed

    • fix: brits imputation test device mismatch by @MaciejSkrabski in https://github.com/WenjieDu/PyPOTS/pull/11
    • Merge branch 'dev' into main by @WenjieDu in https://github.com/WenjieDu/PyPOTS/pull/13
    • feat: add workflow Publish-to-PyPI by @WenjieDu in https://github.com/WenjieDu/PyPOTS/pull/14
    • Merge branch 'dev' into main by @WenjieDu in https://github.com/WenjieDu/PyPOTS/pull/15
    • Specify Conda channels for the dependencies by @WenjieDu in https://github.com/WenjieDu/PyPOTS/pull/18
    • fix the bug of tensors on different devices by @WenjieDu in https://github.com/WenjieDu/PyPOTS/pull/22

    New Contributors

    • @MaciejSkrabski made their first contribution in https://github.com/WenjieDu/PyPOTS/pull/11
    • @WenjieDu made their first contribution in https://github.com/WenjieDu/PyPOTS/pull/13

    Full Changelog: https://github.com/WenjieDu/PyPOTS/compare/v0.0.7...v0.0.8

    Source code(tar.gz)
    Source code(zip)
  • v0.0.7(Jul 12, 2022)

Owner
Wenjie Du
"Do one thing, and do it well."
Wenjie Du
李航《统计学习方法》复现

本项目复现李航《统计学习方法》每一章节的算法 特点: 笔记摘要:在每个文件开头都会有一些核心的摘要 pythonic:这里会用尽可能规范的方式来实现,包括编程风格几乎严格按照PEP8 循序渐进:前期的算法会更list的方式来做计算,可读性比较强,后期几乎完全为numpy.array的计算,并且辅助详

58 Oct 22, 2021
ml4ir: Machine Learning for Information Retrieval

ml4ir: Machine Learning for Information Retrieval | changelog Quickstart → ml4ir Read the Docs | ml4ir pypi | python ReadMe ml4ir is an open source li

Salesforce 77 Jan 06, 2023
A simple guide to MLOps through ZenML and its various integrations.

ZenBytes Join our Slack Community and become part of the ZenML family Give the main ZenML repo a GitHub star to show your love ZenBytes is a series of

ZenML 127 Dec 27, 2022
Code base of KU AIRS: SPARK Autonomous Vehicle Team

KU AIRS: SPARK Autonomous Vehicle Project Check this link for the blog post describing this project and the video of SPARK in simulation and on parkou

Mehmet Enes Erciyes 1 Nov 23, 2021
This repo implements a Topological SLAM: Deep Visual Odometry with Long Term Place Recognition (Loop Closure Detection)

This repo implements a topological SLAM system. Deep Visual Odometry (DF-VO) and Visual Place Recognition are combined to form the topological SLAM system.

Best of Australian Centre for Robotic Vision (ACRV) 32 Jun 23, 2022
Basic Docker Compose for Machine Learning Purposes

Docker-compose for Machine Learning How to use: cd docker-ml-jupyterlab

Chris Chen 1 Oct 29, 2021
Forecasting prices using Facebook/Meta's Prophet model

CryptoForecasting using Machine and Deep learning (Part 1) CryptoForecasting using Machine Learning The main aspect of predicting the stock-related da

1 Nov 27, 2021
Python based GBDT implementation

Py-boost: a research tool for exploring GBDTs Modern gradient boosting toolkits are very complex and are written in low-level programming languages. A

Sberbank AI Lab 20 Sep 21, 2022
MosaicML Composer contains a library of methods, and ways to compose them together for more efficient ML training

MosaicML Composer MosaicML Composer contains a library of methods, and ways to compose them together for more efficient ML training. We aim to ease th

MosaicML 2.8k Jan 06, 2023
Stacked Generalization (Ensemble Learning)

Stacking (stacked generalization) Overview ikki407/stacking - Simple and useful stacking library, written in Python. User can use models of scikit-lea

Ikki Tanaka 192 Dec 23, 2022
A Streamlit demo to interactively visualize Uber pickups in New York City

Streamlit Demo: Uber Pickups in New York City A Streamlit demo written in pure Python to interactively visualize Uber pickups in New York City. View t

Streamlit 230 Dec 28, 2022
Model factory is a ML training platform to help engineers to build ML models at scale

Model Factory Machine learning today is powering many businesses today, e.g., search engine, e-commerce, news or feed recommendation. Training high qu

16 Sep 23, 2022
Model Agnostic Confidence Estimator (MACEST) - A Python library for calibrating Machine Learning models' confidence scores

Model Agnostic Confidence Estimator (MACEST) - A Python library for calibrating Machine Learning models' confidence scores

Oracle 95 Dec 28, 2022
monolish: MONOlithic Liner equation Solvers for Highly-parallel architecture

monolish is a linear equation solver library that monolithically fuses variable data type, matrix structures, matrix data format, vendor specific data transfer APIs, and vendor specific numerical alg

RICOS Co. Ltd. 179 Dec 21, 2022
Python factor analysis library (PCA, CA, MCA, MFA, FAMD)

Prince is a library for doing factor analysis. This includes a variety of methods including principal component analysis (PCA) and correspondence anal

Max Halford 915 Dec 31, 2022
Relevance Vector Machine implementation using the scikit-learn API.

scikit-rvm scikit-rvm is a Python module implementing the Relevance Vector Machine (RVM) machine learning technique using the scikit-learn API. Quicks

James Ritchie 204 Nov 18, 2022
Simulate & classify transient absorption spectroscopy (TAS) spectral features for bulk semiconducting materials (Post-DFT)

PyTASER PyTASER is a Python (3.9+) library and set of command-line tools for classifying spectral features in bulk materials, post-DFT. The goal of th

Materials Design Group 4 Dec 27, 2022
Educational python for Neural Networks, written in pure Python/NumPy.

Educational python for Neural Networks, written in pure Python/NumPy.

127 Oct 27, 2022
A statistical library designed to fill the void in Python's time series analysis capabilities, including the equivalent of R's auto.arima function.

pmdarima Pmdarima (originally pyramid-arima, for the anagram of 'py' + 'arima') is a statistical library designed to fill the void in Python's time se

alkaline-ml 1.3k Dec 22, 2022
Code for the TCAV ML interpretability project

Interpretability Beyond Feature Attribution: Quantitative Testing with Concept Activation Vectors (TCAV) Been Kim, Martin Wattenberg, Justin Gilmer, C

552 Dec 27, 2022