From 0ceeced46aa46668429d6871c52a77cd803d9c8a Mon Sep 17 00:00:00 2001 From: Wenjie Du Date: Fri, 19 Apr 2024 23:17:09 +0800 Subject: [PATCH] refactor: code refactor and docs update; --- pypots/base.py | 6 ++--- pypots/classification/base.py | 30 +++++++++------------ pypots/classification/brits/data.py | 2 +- pypots/classification/brits/model.py | 17 ++++-------- pypots/classification/grud/data.py | 2 +- pypots/classification/grud/model.py | 17 ++++-------- pypots/classification/raindrop/data.py | 2 +- pypots/classification/raindrop/model.py | 17 ++++-------- pypots/classification/template/model.py | 7 +++++ pypots/clustering/base.py | 30 +++++++++------------ pypots/clustering/crli/data.py | 2 +- pypots/clustering/crli/model.py | 17 ++++-------- pypots/clustering/vader/data.py | 2 +- pypots/clustering/vader/model.py | 17 ++++-------- pypots/data/dataset/base.py | 7 ++++- pypots/forecasting/base.py | 35 +++++++++++-------------- pypots/forecasting/bttf/model.py | 25 +++++++----------- pypots/forecasting/csdi/model.py | 26 +++++++----------- pypots/imputation/autoformer/model.py | 22 +++++----------- pypots/imputation/base.py | 34 ++++++++++-------------- pypots/imputation/brits/data.py | 2 +- pypots/imputation/brits/model.py | 21 +++++---------- pypots/imputation/crossformer/model.py | 22 +++++----------- pypots/imputation/csdi/model.py | 22 ++++++---------- pypots/imputation/dlinear/model.py | 22 +++++----------- pypots/imputation/etsformer/model.py | 22 +++++----------- pypots/imputation/fedformer/model.py | 22 +++++----------- pypots/imputation/gpvae/data.py | 2 +- pypots/imputation/gpvae/model.py | 23 +++++----------- pypots/imputation/informer/model.py | 22 +++++----------- pypots/imputation/locf/model.py | 23 ++++++---------- pypots/imputation/mean/model.py | 23 ++++++---------- pypots/imputation/median/model.py | 23 ++++++---------- pypots/imputation/mrnn/data.py | 2 +- pypots/imputation/mrnn/model.py | 21 +++++---------- pypots/imputation/patchtst/model.py | 21 +++++---------- pypots/imputation/saits/data.py | 2 +- pypots/imputation/saits/model.py | 21 +++++---------- pypots/imputation/timesnet/model.py | 24 ++++++----------- pypots/imputation/transformer/model.py | 20 +++++--------- pypots/imputation/usgan/data.py | 2 +- pypots/imputation/usgan/model.py | 20 +++++--------- 42 files changed, 256 insertions(+), 443 deletions(-) diff --git a/pypots/base.py b/pypots/base.py index 699fc098..cba7ea9a 100644 --- a/pypots/base.py +++ b/pypots/base.py @@ -346,7 +346,7 @@ def fit( train_set : The dataset for model training, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for training, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -355,7 +355,7 @@ def fit( val_set : The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -380,7 +380,7 @@ def predict( test_set : The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains diff --git a/pypots/classification/base.py b/pypots/classification/base.py index 817302ec..a758fed3 100644 --- a/pypots/classification/base.py +++ b/pypots/classification/base.py @@ -81,7 +81,7 @@ def fit( train_set : The dataset for model training, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for training, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -90,7 +90,7 @@ def fit( val_set : The dataset for model validating, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -113,15 +113,15 @@ def predict( @abstractmethod def classify( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Classify the input data with the trained model. Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -132,8 +132,7 @@ def classify( array-like, shape [n_samples], Classification results of the given samples. """ - # this is for old API compatibility, will be removed in the future. - # Please implement predict() instead. + raise NotImplementedError @@ -395,7 +394,7 @@ def fit( train_set : The dataset for model training, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for training, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -404,7 +403,7 @@ def fit( val_set : The dataset for model validating, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -427,19 +426,17 @@ def predict( @abstractmethod def classify( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Classify the input data with the trained model. - Warnings - -------- - The method classify is deprecated. Please use `predict()` instead. + Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -450,6 +447,5 @@ def classify( array-like, shape [n_samples], Classification results of the given samples. """ - # this is for old API compatibility, will be removed in the future. - # Please implement predict() instead. + raise NotImplementedError diff --git a/pypots/classification/brits/data.py b/pypots/classification/brits/data.py index 663ba81d..54142512 100644 --- a/pypots/classification/brits/data.py +++ b/pypots/classification/brits/data.py @@ -20,7 +20,7 @@ class DatasetForBRITS(DatasetForBRITS_Imputation): data : The dataset for model input, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for input, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains diff --git a/pypots/classification/brits/model.py b/pypots/classification/brits/model.py index fa0ad349..35c47445 100644 --- a/pypots/classification/brits/model.py +++ b/pypots/classification/brits/model.py @@ -26,7 +26,6 @@ from ..base import BaseNNClassifier from ...optim.adam import Adam from ...optim.base import Optimizer -from ...utils.logging import logger class BRITS(BaseNNClassifier): @@ -266,19 +265,15 @@ def predict( def classify( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Classify the input data with the trained model. - Warnings - -------- - The method classify is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -289,8 +284,6 @@ def classify( array-like, shape [n_samples], Classification results of the given samples. """ - logger.warning( - "🚨DeprecationWarning: The method classify is deprecated. Please use `predict` instead." - ) - result_dict = self.predict(X, file_type=file_type) + + result_dict = self.predict(test_set, file_type=file_type) return result_dict["classification"] diff --git a/pypots/classification/grud/data.py b/pypots/classification/grud/data.py index 99401310..f346628e 100644 --- a/pypots/classification/grud/data.py +++ b/pypots/classification/grud/data.py @@ -23,7 +23,7 @@ class DatasetForGRUD(BaseDataset): data : The dataset for model input, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for input, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains diff --git a/pypots/classification/grud/model.py b/pypots/classification/grud/model.py index a18e78c8..adda99a5 100644 --- a/pypots/classification/grud/model.py +++ b/pypots/classification/grud/model.py @@ -22,7 +22,6 @@ from ..base import BaseNNClassifier from ...optim.adam import Adam from ...optim.base import Optimizer -from ...utils.logging import logger class GRUD(BaseNNClassifier): @@ -238,19 +237,15 @@ def predict( def classify( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Classify the input data with the trained model. - Warnings - -------- - The method classify is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -261,8 +256,6 @@ def classify( array-like, shape [n_samples], Classification results of the given samples. """ - logger.warning( - "🚨DeprecationWarning: The method classify is deprecated. Please use `predict` instead." - ) - result_dict = self.predict(X, file_type=file_type) + + result_dict = self.predict(test_set, file_type=file_type) return result_dict["classification"] diff --git a/pypots/classification/raindrop/data.py b/pypots/classification/raindrop/data.py index 9449976f..05fe0464 100644 --- a/pypots/classification/raindrop/data.py +++ b/pypots/classification/raindrop/data.py @@ -19,7 +19,7 @@ class DatasetForRaindrop(DatasetForGRUD): data : The dataset for model input, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for input, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains diff --git a/pypots/classification/raindrop/model.py b/pypots/classification/raindrop/model.py index 8def46d2..d364908e 100644 --- a/pypots/classification/raindrop/model.py +++ b/pypots/classification/raindrop/model.py @@ -23,7 +23,6 @@ from ...classification.base import BaseNNClassifier from ...optim.adam import Adam from ...optim.base import Optimizer -from ...utils.logging import logger class Raindrop(BaseNNClassifier): @@ -283,19 +282,15 @@ def predict( def classify( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Classify the input data with the trained model. - Warnings - -------- - The method classify is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -306,8 +301,6 @@ def classify( array-like, shape [n_samples], Classification results of the given samples. """ - logger.warning( - "🚨DeprecationWarning: The method classify is deprecated. Please use `predict` instead." - ) - result_dict = self.predict(X, file_type=file_type) + + result_dict = self.predict(test_set, file_type=file_type) return result_dict["classification"] diff --git a/pypots/classification/template/model.py b/pypots/classification/template/model.py index 40f6b252..8703b320 100644 --- a/pypots/classification/template/model.py +++ b/pypots/classification/template/model.py @@ -90,3 +90,10 @@ def predict( file_type: str = "hdf5", ) -> dict: raise NotImplementedError + + def classify( + self, + test_set: Union[dict, str], + file_type: str = "hdf5", + ) -> dict: + raise NotImplementedError diff --git a/pypots/clustering/base.py b/pypots/clustering/base.py index 2ecc46e3..bdf68645 100644 --- a/pypots/clustering/base.py +++ b/pypots/clustering/base.py @@ -81,7 +81,7 @@ def fit( train_set : The dataset for model training, should be a dictionary including the key 'X', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for training, can contain missing values. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains key-value pairs like a dict, and it has to include the key 'X'. @@ -89,7 +89,7 @@ def fit( val_set : The dataset for model validating, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -112,15 +112,15 @@ def predict( @abstractmethod def cluster( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Cluster the input with the trained model. Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -131,8 +131,7 @@ def cluster( array-like, Clustering results. """ - # this is for old API compatibility, will be removed in the future. - # Please implement predict() instead. + raise NotImplementedError @@ -388,7 +387,7 @@ def fit( train_set : The dataset for model training, should be a dictionary including the key 'X', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for training, can contain missing values. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains key-value pairs like a dict, and it has to include the key 'X'. @@ -396,7 +395,7 @@ def fit( val_set : The dataset for model validating, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -419,19 +418,17 @@ def predict( @abstractmethod def cluster( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Cluster the input with the trained model. - Warnings - -------- - The method cluster is deprecated. Please use `predict()` instead. + Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -442,6 +439,5 @@ def cluster( array-like, Clustering results. """ - # this is for old API compatibility, will be removed in the future. - # Please implement predict() instead. + raise NotImplementedError diff --git a/pypots/clustering/crli/data.py b/pypots/clustering/crli/data.py index cf8976a2..ed69e260 100644 --- a/pypots/clustering/crli/data.py +++ b/pypots/clustering/crli/data.py @@ -19,7 +19,7 @@ class DatasetForCRLI(BaseDataset): data : The dataset for model input, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for input, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains diff --git a/pypots/clustering/crli/model.py b/pypots/clustering/crli/model.py index 90651ca0..7b01e6c2 100644 --- a/pypots/clustering/crli/model.py +++ b/pypots/clustering/crli/model.py @@ -385,7 +385,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -445,19 +445,15 @@ def predict( def cluster( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Cluster the input with the trained model. - Warnings - -------- - The method cluster is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -469,9 +465,6 @@ def cluster( Clustering results. """ - logger.warning( - "🚨DeprecationWarning: The method cluster is deprecated. Please use `predict` instead." - ) - result_dict = self.predict(X, file_type) + result_dict = self.predict(test_set, file_type=file_type) return result_dict["clustering"] diff --git a/pypots/clustering/vader/data.py b/pypots/clustering/vader/data.py index ea718397..86de0760 100644 --- a/pypots/clustering/vader/data.py +++ b/pypots/clustering/vader/data.py @@ -19,7 +19,7 @@ class DatasetForVaDER(BaseDataset): data : The dataset for model input, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for input, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains diff --git a/pypots/clustering/vader/model.py b/pypots/clustering/vader/model.py index a9b151dc..4e683f53 100644 --- a/pypots/clustering/vader/model.py +++ b/pypots/clustering/vader/model.py @@ -399,7 +399,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -498,19 +498,15 @@ def func_to_apply( def cluster( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> Union[np.ndarray]: """Cluster the input with the trained model. - Warnings - -------- - The method cluster is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -522,9 +518,6 @@ def cluster( Clustering results. """ - logger.warning( - "🚨DeprecationWarning: The method cluster is deprecated. Please use `predict` instead." - ) - result_dict = self.predict(X, file_type) + result_dict = self.predict(test_set, file_type=file_type) return result_dict["clustering"] diff --git a/pypots/data/dataset/base.py b/pypots/data/dataset/base.py index 9388c351..b2cbbbf7 100644 --- a/pypots/data/dataset/base.py +++ b/pypots/data/dataset/base.py @@ -255,12 +255,17 @@ def _check_array_input( Parameters ---------- X : - Time-series data that must have a shape like [n_samples, expected_n_steps, expected_n_features]. + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), + n_features], or a path string locating a data file, e.g. h5 file. X_ori : If X is with artificial missingness, X_ori is the original X without artificial missing values. It must have the same shape as X. If X_ori is with original missing values, should be left as NaN. + X_pred : + The forecasting results of X , should be array-like of shape [n_samples, sequence length (n_steps), + n_features], or a path string locating a data file, e.g. h5 file. + y : Labels of time-series samples (X) that must have a shape like [n_samples] or [n_samples, n_classes]. diff --git a/pypots/forecasting/base.py b/pypots/forecasting/base.py index f1ef2e8f..0b8a153d 100644 --- a/pypots/forecasting/base.py +++ b/pypots/forecasting/base.py @@ -76,7 +76,7 @@ def fit( train_set : The dataset for model training, should be a dictionary including the key 'X', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for training, can contain missing values. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains key-value pairs like a dict, and it has to include the key 'X'. @@ -84,7 +84,7 @@ def fit( val_set : The dataset for model validating, should be a dictionary including the key 'X', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validation, can contain missing values. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains key-value pairs like a dict, and it has to include the key 'X'. @@ -106,26 +106,26 @@ def predict( @abstractmethod def forecast( self, - X: dict or str, + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Forecast the future the input with the trained model. Parameters ---------- - X : - Time-series data containing missing values. Shape [n_samples, sequence length (time steps), n_features]. + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), + n_features], or a path string locating a data file, e.g. h5 file. file_type : The type of the given file if X is a path string. Returns ------- - array-like, shape [n_samples, prediction_horizon, n_features], + array-like, shape [n_samples, n_pred_steps, n_features], Forecasting results. """ - # this is for old API compatibility, will be removed in the future. - # Please implement predict() instead. + raise NotImplementedError @@ -389,7 +389,7 @@ def fit( train_set : The dataset for model training, should be a dictionary including the key 'X', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for training, can contain missing values. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains key-value pairs like a dict, and it has to include the key 'X'. @@ -397,7 +397,7 @@ def fit( val_set : The dataset for model validating, should be a dictionary including the key 'X', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validation, can contain missing values. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains key-value pairs like a dict, and it has to include the key 'X'. @@ -419,28 +419,23 @@ def predict( @abstractmethod def forecast( self, - X: dict or str, + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Forecast the future the input with the trained model. - Warnings - -------- - The method forecast is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - Time-series data containing missing values. Shape [n_samples, sequence length (time steps), n_features]. + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), + n_features], or a path string locating a data file, e.g. h5 file. file_type : The type of the given file if X is a path string. Returns ------- - array-like, shape [n_samples, prediction_horizon, n_features], + array-like, shape [n_samples, n_pred_steps, n_features], Forecasting results. """ - # this is for old API compatibility, will be removed in the future. - # Please implement predict() instead. raise NotImplementedError diff --git a/pypots/forecasting/bttf/model.py b/pypots/forecasting/bttf/model.py index ab530058..040b0b95 100644 --- a/pypots/forecasting/bttf/model.py +++ b/pypots/forecasting/bttf/model.py @@ -23,7 +23,6 @@ from .core import BTTF_forecast from ..base import BaseForecaster -from ...utils.logging import logger class BTTF(BaseForecaster): @@ -139,31 +138,25 @@ def predict( def forecast( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: - """Forecast the future the input with the trained model. - - Warnings - -------- - The method forecast is deprecated. Please use `predict()` instead. + """Forecast the future of the input with the trained model. Parameters ---------- - X : - Time-series data containing missing values. Shape [n_samples, sequence length (time steps), n_features]. + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), + n_features], or a path string locating a data file, e.g. h5 file. file_type : The type of the given file if X is a path string. Returns ------- - array-like, shape [n_samples, prediction_horizon, n_features], + array-like, shape [n_samples, n_pred_steps, n_features], Forecasting results. """ - logger.warning( - "🚨DeprecationWarning: The method forecast is deprecated. Please use `predict` instead." - ) - result_dict = self.predict(X, file_type=file_type) - forecasting = result_dict["forecasting"] - return forecasting + + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["forecasting"] diff --git a/pypots/forecasting/csdi/model.py b/pypots/forecasting/csdi/model.py index 68f6a412..506e54bb 100644 --- a/pypots/forecasting/csdi/model.py +++ b/pypots/forecasting/csdi/model.py @@ -406,7 +406,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -466,19 +466,15 @@ def predict( def forecast( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: - """Impute missing values in the given data with the trained model. - - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. + """Forecast the future of the input with the trained model. Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -486,11 +482,9 @@ def forecast( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], - Imputed data. + array-like, shape [n_samples, n_pred_steps, n_features], + Forecasting results. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["forecasting"] + + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["forecasting"] diff --git a/pypots/imputation/autoformer/model.py b/pypots/imputation/autoformer/model.py index edafd0a5..f8601fda 100644 --- a/pypots/imputation/autoformer/model.py +++ b/pypots/imputation/autoformer/model.py @@ -27,7 +27,6 @@ from ...data.dataset import BaseDataset from ...optim.adam import Adam from ...optim.base import Optimizer -from ...utils.logging import logger class Autoformer(BaseNNImputer): @@ -257,7 +256,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -305,19 +304,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -325,12 +320,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/base.py b/pypots/imputation/base.py index 18218c3e..f08d310f 100644 --- a/pypots/imputation/base.py +++ b/pypots/imputation/base.py @@ -77,7 +77,7 @@ def fit( train_set : The dataset for model training, should be a dictionary including the key 'X', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for training, can contain missing values. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains key-value pairs like a dict, and it has to include the key 'X'. @@ -85,7 +85,7 @@ def fit( val_set : The dataset for model validating, should be a dictionary including the key 'X', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains key-value pairs like a dict, and it has to include the key 'X'. @@ -107,15 +107,15 @@ def predict( @abstractmethod def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -123,11 +123,10 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - # this is for old API compatibility, will be removed in the future. - # Please implement predict() instead. + raise NotImplementedError @@ -392,7 +391,7 @@ def fit( train_set : The dataset for model training, should be a dictionary including the key 'X', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for training, can contain missing values. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains key-value pairs like a dict, and it has to include the key 'X'. @@ -400,7 +399,7 @@ def fit( val_set : The dataset for model validating, should be a dictionary including the key 'X', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains key-value pairs like a dict, and it has to include the key 'X'. @@ -422,19 +421,15 @@ def predict( @abstractmethod def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -442,9 +437,8 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - # this is for old API compatibility, will be removed in the future. - # Please implement predict() instead. + raise NotImplementedError diff --git a/pypots/imputation/brits/data.py b/pypots/imputation/brits/data.py index 589a5d5f..6c51405b 100644 --- a/pypots/imputation/brits/data.py +++ b/pypots/imputation/brits/data.py @@ -22,7 +22,7 @@ class DatasetForBRITS(BaseDataset): data : The dataset for model input, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for input, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains diff --git a/pypots/imputation/brits/model.py b/pypots/imputation/brits/model.py index 68d71355..ed72d4d5 100644 --- a/pypots/imputation/brits/model.py +++ b/pypots/imputation/brits/model.py @@ -27,7 +27,6 @@ from ...data.checking import key_in_data_set from ...optim.adam import Adam from ...optim.base import Optimizer -from ...utils.logging import logger class BRITS(BaseNNImputer): @@ -260,19 +259,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -280,11 +275,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/crossformer/model.py b/pypots/imputation/crossformer/model.py index a2076d95..76b3e115 100644 --- a/pypots/imputation/crossformer/model.py +++ b/pypots/imputation/crossformer/model.py @@ -28,7 +28,6 @@ from ...data.dataset import BaseDataset from ...optim.adam import Adam from ...optim.base import Optimizer -from ...utils.logging import logger class Crossformer(BaseNNImputer): @@ -264,7 +263,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -312,19 +311,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -332,12 +327,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/csdi/model.py b/pypots/imputation/csdi/model.py index bcfdc29d..e463ad84 100644 --- a/pypots/imputation/csdi/model.py +++ b/pypots/imputation/csdi/model.py @@ -390,7 +390,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -443,19 +443,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -463,11 +459,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/dlinear/model.py b/pypots/imputation/dlinear/model.py index af7ba286..bc53db7b 100644 --- a/pypots/imputation/dlinear/model.py +++ b/pypots/imputation/dlinear/model.py @@ -28,7 +28,6 @@ from ...data.dataset import BaseDataset from ...optim.adam import Adam from ...optim.base import Optimizer -from ...utils.logging import logger class DLinear(BaseNNImputer): @@ -235,7 +234,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -283,19 +282,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -303,12 +298,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/etsformer/model.py b/pypots/imputation/etsformer/model.py index 94a253e1..ead457a2 100644 --- a/pypots/imputation/etsformer/model.py +++ b/pypots/imputation/etsformer/model.py @@ -27,7 +27,6 @@ from ...data.dataset import BaseDataset from ...optim.adam import Adam from ...optim.base import Optimizer -from ...utils.logging import logger class ETSformer(BaseNNImputer): @@ -257,7 +256,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -305,19 +304,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -325,12 +320,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/fedformer/model.py b/pypots/imputation/fedformer/model.py index dfda3740..33185bea 100644 --- a/pypots/imputation/fedformer/model.py +++ b/pypots/imputation/fedformer/model.py @@ -27,7 +27,6 @@ from ...data.dataset import BaseDataset from ...optim.adam import Adam from ...optim.base import Optimizer -from ...utils.logging import logger class FEDformer(BaseNNImputer): @@ -271,7 +270,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -319,19 +318,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -339,12 +334,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/gpvae/data.py b/pypots/imputation/gpvae/data.py index 27b3b456..61cc09a1 100644 --- a/pypots/imputation/gpvae/data.py +++ b/pypots/imputation/gpvae/data.py @@ -20,7 +20,7 @@ class DatasetForGPVAE(BaseDataset): data : The dataset for model input, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for input, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains diff --git a/pypots/imputation/gpvae/model.py b/pypots/imputation/gpvae/model.py index 1ff234c9..a2f5675d 100644 --- a/pypots/imputation/gpvae/model.py +++ b/pypots/imputation/gpvae/model.py @@ -408,7 +408,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -458,20 +458,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", - n_sampling_times: int = 1, ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -479,13 +474,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict( - X, file_type=file_type, n_sampling_times=n_sampling_times - ) + + results_dict = self.predict(test_set, file_type=file_type) return results_dict["imputation"] diff --git a/pypots/imputation/informer/model.py b/pypots/imputation/informer/model.py index 9429485e..09ae38a9 100644 --- a/pypots/imputation/informer/model.py +++ b/pypots/imputation/informer/model.py @@ -28,7 +28,6 @@ from ...data.dataset import BaseDataset from ...optim.adam import Adam from ...optim.base import Optimizer -from ...utils.logging import logger class Informer(BaseNNImputer): @@ -252,7 +251,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -300,19 +299,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -320,12 +315,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/locf/model.py b/pypots/imputation/locf/model.py index b88e9e7a..d20ebcfc 100644 --- a/pypots/imputation/locf/model.py +++ b/pypots/imputation/locf/model.py @@ -15,7 +15,6 @@ from .core import locf_numpy, locf_torch from ..base import BaseImputer -from ...utils.logging import logger class LOCF(BaseImputer): @@ -82,7 +81,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -127,19 +126,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -147,11 +142,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/mean/model.py b/pypots/imputation/mean/model.py index 33582f8d..129f15ec 100644 --- a/pypots/imputation/mean/model.py +++ b/pypots/imputation/mean/model.py @@ -14,7 +14,6 @@ import torch from ..base import BaseImputer -from ...utils.logging import logger class Mean(BaseImputer): @@ -56,7 +55,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -113,19 +112,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -133,11 +128,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/median/model.py b/pypots/imputation/median/model.py index 6295aa5f..ffa315e4 100644 --- a/pypots/imputation/median/model.py +++ b/pypots/imputation/median/model.py @@ -14,7 +14,6 @@ import torch from ..base import BaseImputer -from ...utils.logging import logger class Median(BaseImputer): @@ -56,7 +55,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -114,19 +113,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -134,11 +129,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/mrnn/data.py b/pypots/imputation/mrnn/data.py index cb228f53..a66155c8 100644 --- a/pypots/imputation/mrnn/data.py +++ b/pypots/imputation/mrnn/data.py @@ -22,7 +22,7 @@ class DatasetForMRNN(BaseDataset): data : The dataset for model input, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for input, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains diff --git a/pypots/imputation/mrnn/model.py b/pypots/imputation/mrnn/model.py index 378cd5c3..c8f733d8 100644 --- a/pypots/imputation/mrnn/model.py +++ b/pypots/imputation/mrnn/model.py @@ -26,7 +26,6 @@ from ...data.checking import key_in_data_set from ...optim.adam import Adam from ...optim.base import Optimizer -from ...utils.logging import logger class MRNN(BaseNNImputer): @@ -260,19 +259,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -280,11 +275,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/patchtst/model.py b/pypots/imputation/patchtst/model.py index b4c72c4d..02436daa 100644 --- a/pypots/imputation/patchtst/model.py +++ b/pypots/imputation/patchtst/model.py @@ -285,7 +285,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -333,19 +333,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -353,12 +349,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/saits/data.py b/pypots/imputation/saits/data.py index 0c25b0f8..a37198bb 100644 --- a/pypots/imputation/saits/data.py +++ b/pypots/imputation/saits/data.py @@ -23,7 +23,7 @@ class DatasetForSAITS(BaseDataset): data : The dataset for model input, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for input, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains diff --git a/pypots/imputation/saits/model.py b/pypots/imputation/saits/model.py index a45927f6..d8dd389c 100644 --- a/pypots/imputation/saits/model.py +++ b/pypots/imputation/saits/model.py @@ -294,7 +294,7 @@ def predict( test_set : The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -378,19 +378,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -398,12 +394,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/timesnet/model.py b/pypots/imputation/timesnet/model.py index 419470b2..228ec540 100644 --- a/pypots/imputation/timesnet/model.py +++ b/pypots/imputation/timesnet/model.py @@ -23,11 +23,10 @@ from .core import _TimesNet from .data import DatasetForTimesNet from ..base import BaseNNImputer -from ...data.dataset import BaseDataset from ...data.checking import key_in_data_set +from ...data.dataset import BaseDataset from ...optim.adam import Adam from ...optim.base import Optimizer -from ...utils.logging import logger class TimesNet(BaseNNImputer): @@ -247,7 +246,7 @@ def predict( test_set : dict or str The dataset for model validating, should be a dictionary including keys as 'X', or a path string locating a data file supported by PyPOTS (e.g. h5 file). - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for validating, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains @@ -295,19 +294,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -315,12 +310,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/transformer/model.py b/pypots/imputation/transformer/model.py index 46ee13ab..6ecda52e 100644 --- a/pypots/imputation/transformer/model.py +++ b/pypots/imputation/transformer/model.py @@ -304,19 +304,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -324,11 +320,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"] diff --git a/pypots/imputation/usgan/data.py b/pypots/imputation/usgan/data.py index 40e6ee77..f261cf5b 100644 --- a/pypots/imputation/usgan/data.py +++ b/pypots/imputation/usgan/data.py @@ -18,7 +18,7 @@ class DatasetForUSGAN(DatasetForBRITS): data : The dataset for model input, should be a dictionary including keys as 'X' and 'y', or a path string locating a data file. - If it is a dict, X should be array-like of shape [n_samples, sequence length (time steps), n_features], + If it is a dict, X should be array-like of shape [n_samples, sequence length (n_steps), n_features], which is time-series data for input, can contain missing values, and y should be array-like of shape [n_samples], which is classification labels of X. If it is a path string, the path should point to a data file, e.g. a h5 file, which contains diff --git a/pypots/imputation/usgan/model.py b/pypots/imputation/usgan/model.py index 1f684e92..cd68de4d 100644 --- a/pypots/imputation/usgan/model.py +++ b/pypots/imputation/usgan/model.py @@ -441,19 +441,15 @@ def predict( def impute( self, - X: Union[dict, str], + test_set: Union[dict, str], file_type: str = "hdf5", ) -> np.ndarray: """Impute missing values in the given data with the trained model. - Warnings - -------- - The method impute is deprecated. Please use `predict()` instead. - Parameters ---------- - X : - The data samples for testing, should be array-like of shape [n_samples, sequence length (time steps), + test_set : + The data samples for testing, should be array-like of shape [n_samples, sequence length (n_steps), n_features], or a path string locating a data file, e.g. h5 file. file_type : @@ -461,11 +457,9 @@ def impute( Returns ------- - array-like, shape [n_samples, sequence length (time steps), n_features], + array-like, shape [n_samples, sequence length (n_steps), n_features], Imputed data. """ - logger.warning( - "🚨DeprecationWarning: The method impute is deprecated. Please use `predict` instead." - ) - results_dict = self.predict(X, file_type=file_type) - return results_dict["imputation"] + + result_dict = self.predict(test_set, file_type=file_type) + return result_dict["imputation"]