Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix model saving issue and update docs #524

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ docs/_build
# ignore specific kinds of files like all PDFs
*.pdf
*.ipynb
*TODO

# ignore executable and config files
*.sh
*.yml
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ algorithms, PyPOTS is going to have unified APIs together with detailed document
algorithms as tutorials.

🤗 **Please** star this repo to help others notice PyPOTS if you think it is a useful toolkit.
**Please** kindly [cite PyPOTS](https://github.com/WenjieDu/PyPOTS#-citing-pypots) in your publications if it helps with your research.
**Please** kindly [cite PyPOTS](https://github.com/WenjieDu/PyPOTS#-citing-pypots) in your publications if it helps with
your research.
This really means a lot to our open-source research. Thank you!

The rest of this readme file is organized as follows:
Expand All @@ -98,9 +99,9 @@ corresponding task (note that models will be continuously updated in the future
currently supported. Stay tuned❗️).

🌟 Since **v0.2**, all neural-network models in PyPOTS has got hyperparameter-optimization support.
This functionality is implemented with the [Microsoft NNI](https://github.com/microsoft/nni) framework. You may want to refer to our time-series
imputation survey repo [Awesome_Imputation](https://github.com/WenjieDu/Awesome_Imputation) to see how to config and
tune the hyperparameters.
This functionality is implemented with the [Microsoft NNI](https://github.com/microsoft/nni) framework. You may want to
refer to our time-series imputation survey repo [Awesome_Imputation](https://github.com/WenjieDu/Awesome_Imputation)
to see how to config and tune the hyperparameters.

🔥 Note that all models whose name with `🧑‍🔧` in the table (e.g. Transformer, iTransformer, Informer etc.) are not
originally proposed as algorithms for POTS data in their papers, and they cannot directly accept time series with
Expand Down Expand Up @@ -225,7 +226,9 @@ for a guideline with more details.

PyPOTS is available on both [PyPI](https://pypi.python.org/pypi/pypots)
and [Anaconda](https://anaconda.org/conda-forge/pypots).
You can install PyPOTS like below as well as TSDB and PyGrinder:
You can install PyPOTS like below as well as
[TSDB](https://github.com/WenjieDu/TSDB),[PyGrinder](https://github.com/WenjieDu/PyGrinder),
[BenchPOTS](https://github.com/WenjieDu/BenchPOTS), and [AI4TS](https://github.com/WenjieDu/AI4TS):

``` bash
# via pip
Expand All @@ -235,8 +238,8 @@ pip install pypots --upgrade # update pypots to the latest version
pip install https://github.com/WenjieDu/PyPOTS/archive/main.zip

# via conda
conda install -c conda-forge pypots # the first time installation
conda update -c conda-forge pypots # update pypots to the latest version
conda install conda-forge::pypots # the first time installation
conda update conda-forge::pypots # update pypots to the latest version
```

## ❖ Usage
Expand Down
151 changes: 78 additions & 73 deletions README_zh.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ It is recommended to use **pip** or **conda** for PyPOTS installation as shown b
pip install https://github.com/WenjieDu/PyPOTS/archive/main.zip

# via conda
conda install -c conda-forge pypots # the first time installation
conda update -c conda-forge pypots # update pypots to the latest version
conda install conda-forge::pypots # the first time installation
conda update conda-forge::pypots # update pypots to the latest version


Required Dependencies
Expand Down
19 changes: 14 additions & 5 deletions docs/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,17 @@ @article{bai2018tcn
}

@article{zhan2024tefn,
title={Time Evidence Fusion Network: Multi-source View in Long-Term Time Series Forecasting},
author={Zhan, Tianxiang and He, Yuanpeng and Li, Zhen and Deng, Yong},
journal={arXiv preprint arXiv:2405.06419},
year={2024}
}
title={Time Evidence Fusion Network: Multi-source View in Long-Term Time Series Forecasting},
author={Zhan, Tianxiang and He, Yuanpeng and Li, Zhen and Deng, Yong},
journal={arXiv preprint arXiv:2405.06419},
year={2024}
}

@inproceedings{jin2024timellm,
title={Time-{LLM}: Time Series Forecasting by Reprogramming Large Language Models},
author={Ming Jin and Shiyu Wang and Lintao Ma and Zhixuan Chu and James Y. Zhang and Xiaoming Shi and Pin-Yu Chen and Yuxuan Liang and Yuan-Fang Li and Shirui Pan and Qingsong Wen},
booktitle={The Twelfth International Conference on Learning Representations},
year={2024},
url={https://openreview.net/forum?id=Unb5CVPtae}
}

4 changes: 2 additions & 2 deletions pypots/classification/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ def _train_model(

# save the model if necessary
self._auto_save_model_if_necessary(
confirm_saving=self.best_epoch == epoch,
saving_name=f"{self.__class__.__name__}_epoch{epoch}_loss{mean_loss}",
confirm_saving=self.best_epoch == epoch and self.model_saving_strategy == "better",
saving_name=f"{self.__class__.__name__}_epoch{epoch}_loss{mean_loss:.4f}",
)

if os.getenv("enable_tuning", False):
Expand Down
2 changes: 1 addition & 1 deletion pypots/classification/brits/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/classification/grud/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/classification/raindrop/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
4 changes: 2 additions & 2 deletions pypots/clustering/crli/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def _train_model(

# save the model if necessary
self._auto_save_model_if_necessary(
confirm_saving=self.best_epoch == epoch,
confirm_saving=self.best_epoch == epoch and self.model_saving_strategy == "better",
saving_name=f"{self.__class__.__name__}_epoch{epoch}_loss{mean_loss:.4f}",
)

Expand Down Expand Up @@ -354,7 +354,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
6 changes: 3 additions & 3 deletions pypots/clustering/vader/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ def _train_model(

# save the model if necessary
self._auto_save_model_if_necessary(
confirm_saving=self.best_epoch == epoch,
saving_name=f"{self.__class__.__name__}_epoch{epoch}_loss{mean_loss}",
confirm_saving=self.best_epoch == epoch and self.model_saving_strategy == "better",
saving_name=f"{self.__class__.__name__}_epoch{epoch}_loss{mean_loss:.4f}",
)

if os.getenv("enable_tuning", False):
Expand Down Expand Up @@ -367,7 +367,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
4 changes: 2 additions & 2 deletions pypots/forecasting/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ def _train_model(

# save the model if necessary
self._auto_save_model_if_necessary(
confirm_saving=self.best_epoch == epoch,
saving_name=f"{self.__class__.__name__}_epoch{epoch}_loss{mean_loss}",
confirm_saving=self.best_epoch == epoch and self.model_saving_strategy == "better",
saving_name=f"{self.__class__.__name__}_epoch{epoch}_loss{mean_loss:.4f}",
)

if os.getenv("enable_tuning", False):
Expand Down
6 changes: 3 additions & 3 deletions pypots/forecasting/csdi/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ def _train_model(

# save the model if necessary
self._auto_save_model_if_necessary(
confirm_saving=self.best_epoch == epoch,
saving_name=f"{self.__class__.__name__}_epoch{epoch}_loss{mean_loss}",
confirm_saving=self.best_epoch == epoch and self.model_saving_strategy == "better",
saving_name=f"{self.__class__.__name__}_epoch{epoch}_loss{mean_loss:.4f}",
)

if os.getenv("enable_tuning", False):
Expand Down Expand Up @@ -379,7 +379,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/autoformer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
4 changes: 2 additions & 2 deletions pypots/imputation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ def _train_model(

# save the model if necessary
self._auto_save_model_if_necessary(
confirm_saving=self.best_epoch == epoch,
saving_name=f"{self.__class__.__name__}_epoch{epoch}_loss{mean_loss}",
confirm_saving=self.best_epoch == epoch and self.model_saving_strategy == "better",
saving_name=f"{self.__class__.__name__}_epoch{epoch}_loss{mean_loss:.4f}",
)

if os.getenv("enable_tuning", False):
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/brits/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/crossformer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
6 changes: 3 additions & 3 deletions pypots/imputation/csdi/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ def _train_model(

# save the model if necessary
self._auto_save_model_if_necessary(
confirm_saving=self.best_epoch == epoch,
saving_name=f"{self.__class__.__name__}_epoch{epoch}_loss{mean_loss}",
confirm_saving=self.best_epoch == epoch and self.model_saving_strategy == "better",
saving_name=f"{self.__class__.__name__}_epoch{epoch}_loss{mean_loss:.4f}",
)

if os.getenv("enable_tuning", False):
Expand Down Expand Up @@ -363,7 +363,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/dlinear/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/etsformer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/fedformer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/film/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/frets/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
6 changes: 3 additions & 3 deletions pypots/imputation/gpvae/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ def _train_model(

# save the model if necessary
self._auto_save_model_if_necessary(
confirm_saving=self.best_epoch == epoch,
saving_name=f"{self.__class__.__name__}_epoch{epoch}_loss{mean_loss}",
confirm_saving=self.best_epoch == epoch and self.model_saving_strategy == "better",
saving_name=f"{self.__class__.__name__}_epoch{epoch}_loss{mean_loss:.4f}",
)

if os.getenv("enable_tuning", False):
Expand Down Expand Up @@ -377,7 +377,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/grud/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/imputeformer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/informer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/itransformer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/koopa/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/micn/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/moderntcn/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
2 changes: 1 addition & 1 deletion pypots/imputation/mrnn/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def fit(
self.model.eval() # set the model as eval status to freeze it.

# Step 3: save the model if necessary
self._auto_save_model_if_necessary(confirm_saving=True)
self._auto_save_model_if_necessary(confirm_saving=self.model_saving_strategy == "best")

def predict(
self,
Expand Down
Loading
Loading