From d6d9af8b317f6edc36de14ceaef8d2f8cd91f168 Mon Sep 17 00:00:00 2001 From: Tony Bagnall Date: Wed, 27 Nov 2024 12:46:53 +0000 Subject: [PATCH 1/5] acf and binsegment --- aeon/segmentation/_binseg.py | 4 ++-- aeon/testing/testing_config.py | 30 ++++++++++++++--------------- aeon/transformations/series/_acf.py | 12 ++++++------ 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/aeon/segmentation/_binseg.py b/aeon/segmentation/_binseg.py index af64959000..473ae91d33 100644 --- a/aeon/segmentation/_binseg.py +++ b/aeon/segmentation/_binseg.py @@ -79,8 +79,8 @@ def _predict(self, X: np.ndarray): List of change points found in X. """ X = X.squeeze() - self.found_cps = self._run_binseg(X) - return self.found_cps + found_cps = self._run_binseg(X) + return found_cps def get_fitted_params(self): """Get fitted parameters. diff --git a/aeon/testing/testing_config.py b/aeon/testing/testing_config.py index 41477dead2..f3cfa128e1 100644 --- a/aeon/testing/testing_config.py +++ b/aeon/testing/testing_config.py @@ -56,23 +56,23 @@ "GreedyGaussianSegmenter": ["check_non_state_changing_method"], "ClaSPSegmenter": ["check_non_state_changing_method"], "HMMSegmenter": ["check_non_state_changing_method"], - "BinSegSegmenter": ["check_non_state_changing_method"], - "QUANTTransformer": ["check_non_state_changing_method"], - "MatrixProfileSeriesTransformer": ["check_non_state_changing_method"], - "PLASeriesTransformer": ["check_non_state_changing_method"], - "AutoCorrelationSeriesTransformer": ["check_non_state_changing_method"], - "SIVSeriesTransformer": ["check_non_state_changing_method"], - "RocketClassifier": ["check_non_state_changing_method"], - "MiniRocketClassifier": ["check_non_state_changing_method"], - "MultiRocketClassifier": ["check_non_state_changing_method"], - "RocketRegressor": ["check_non_state_changing_method"], - "MiniRocketRegressor": ["check_non_state_changing_method"], - "MultiRocketRegressor": ["check_non_state_changing_method"], - "RSTSF": ["check_non_state_changing_method"], + # "BinSegSegmenter": ["check_non_state_changing_method"], + # "QUANTTransformer": ["check_non_state_changing_method"], + # "MatrixProfileSeriesTransformer": ["check_non_state_changing_method"], + # "PLASeriesTransformer": ["check_non_state_changing_method"], + # "AutoCorrelationSeriesTransformer": ["check_non_state_changing_method"], + # "SIVSeriesTransformer": ["check_non_state_changing_method"], + # "RocketClassifier": ["check_non_state_changing_method"], + # "MiniRocketClassifier": ["check_non_state_changing_method"], + # "MultiRocketClassifier": ["check_non_state_changing_method"], + # "RocketRegressor": ["check_non_state_changing_method"], + # "MiniRocketRegressor": ["check_non_state_changing_method"], + # "MultiRocketRegressor": ["check_non_state_changing_method"], + # "RSTSF": ["check_non_state_changing_method"], # Keeps length during predict to avoid recomputing means and std of data in fit # if the next predict calls uses the same query length parameter. - "QuerySearch": ["check_non_state_changing_method"], - "SeriesSearch": ["check_non_state_changing_method"], + # "QuerySearch": ["check_non_state_changing_method"], + # "SeriesSearch": ["check_non_state_changing_method"], # Unknown issue not producing the same results "RDSTRegressor": ["check_regressor_against_expected_results"], "RISTRegressor": ["check_regressor_against_expected_results"], diff --git a/aeon/transformations/series/_acf.py b/aeon/transformations/series/_acf.py index 1e354cba02..18f596fc14 100644 --- a/aeon/transformations/series/_acf.py +++ b/aeon/transformations/series/_acf.py @@ -67,18 +67,18 @@ def _transform(self, X, y=None): """ # statsmodels acf function uses min(10 * np.log10(nobs), nobs - 1) if self.n_lags is None: - self._n_lags = int(max(1, X.shape[1] / 4)) + n_lags = int(max(1, X.shape[1] / 4)) else: - self._n_lags = int(self.n_lags) - if self._n_lags < 1: - self._n_lags = 1 - if X.shape[1] - self._n_lags < 3: + n_lags = int(self.n_lags) + if n_lags < 1: + n_lags = 1 + if X.shape[1] - n_lags < 3: raise ValueError( f"The number of lags is too large for the length of the " f"series, autocorrelation would be calculated with just" f"{X.shape[1]-self._n_lags} observations." ) - return self._acf(X, max_lag=self._n_lags) + return self._acf(X, max_lag=n_lags) @staticmethod @njit(cache=True, fastmath=True) From ea5f0db51f2b9c00ba813d0606ac9fa7d5069897 Mon Sep 17 00:00:00 2001 From: Tony Bagnall Date: Wed, 27 Nov 2024 13:06:02 +0000 Subject: [PATCH 2/5] pla --- aeon/segmentation/_binseg.py | 8 +++----- aeon/testing/testing_config.py | 8 ++++---- aeon/transformations/series/_matrix_profile.py | 4 ++-- aeon/transformations/series/_pla.py | 8 ++++---- aeon/transformations/series/_siv.py | 13 +++++++------ 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/aeon/segmentation/_binseg.py b/aeon/segmentation/_binseg.py index 473ae91d33..74b0eeabcc 100644 --- a/aeon/segmentation/_binseg.py +++ b/aeon/segmentation/_binseg.py @@ -60,9 +60,9 @@ class BinSegSegmenter(BaseSegmenter): def __init__(self, n_cps=1, model="l2", min_size=2, jump=5): self.n_cps = n_cps + self.model = model self.min_size = min_size self.jump = jump - self.model = model super().__init__(n_segments=n_cps + 1, axis=1) def _predict(self, X: np.ndarray): @@ -97,11 +97,9 @@ def _run_binseg(self, X): binseg = rpt.Binseg( model=self.model, min_size=self.min_size, jump=self.jump ).fit(X) - self.found_cps = np.array( - binseg.predict(n_bkps=self.n_cps)[:-1], dtype=np.int64 - ) + found_cps = np.array(binseg.predict(n_bkps=self.n_cps)[:-1], dtype=np.int64) - return self.found_cps + return found_cps def _get_interval_series(self, X, found_cps): """Get the segmentation results based on the found change points. diff --git a/aeon/testing/testing_config.py b/aeon/testing/testing_config.py index f3cfa128e1..89893db138 100644 --- a/aeon/testing/testing_config.py +++ b/aeon/testing/testing_config.py @@ -56,7 +56,7 @@ "GreedyGaussianSegmenter": ["check_non_state_changing_method"], "ClaSPSegmenter": ["check_non_state_changing_method"], "HMMSegmenter": ["check_non_state_changing_method"], - # "BinSegSegmenter": ["check_non_state_changing_method"], + "BinSegSegmenter": ["check_non_state_changing_method"], # "QUANTTransformer": ["check_non_state_changing_method"], # "MatrixProfileSeriesTransformer": ["check_non_state_changing_method"], # "PLASeriesTransformer": ["check_non_state_changing_method"], @@ -68,11 +68,11 @@ # "RocketRegressor": ["check_non_state_changing_method"], # "MiniRocketRegressor": ["check_non_state_changing_method"], # "MultiRocketRegressor": ["check_non_state_changing_method"], - # "RSTSF": ["check_non_state_changing_method"], + "RSTSF": ["check_non_state_changing_method"], # Keeps length during predict to avoid recomputing means and std of data in fit # if the next predict calls uses the same query length parameter. - # "QuerySearch": ["check_non_state_changing_method"], - # "SeriesSearch": ["check_non_state_changing_method"], + "QuerySearch": ["check_non_state_changing_method"], + "SeriesSearch": ["check_non_state_changing_method"], # Unknown issue not producing the same results "RDSTRegressor": ["check_regressor_against_expected_results"], "RISTRegressor": ["check_regressor_against_expected_results"], diff --git a/aeon/transformations/series/_matrix_profile.py b/aeon/transformations/series/_matrix_profile.py index 00832c4eab..79a0a08044 100644 --- a/aeon/transformations/series/_matrix_profile.py +++ b/aeon/transformations/series/_matrix_profile.py @@ -68,5 +68,5 @@ def _transform(self, X, y=None): X = X.squeeze() - self.matrix_profile_ = stumpy.stump(X, self.window_length) - return self.matrix_profile_[:, 0].astype("float") + matrix_profile = stumpy.stump(X, self.window_length) + return matrix_profile[:, 0].astype("float") diff --git a/aeon/transformations/series/_pla.py b/aeon/transformations/series/_pla.py index 4337ec0ef8..92fd74e82f 100644 --- a/aeon/transformations/series/_pla.py +++ b/aeon/transformations/series/_pla.py @@ -62,8 +62,8 @@ class PLASeriesTransformer(BaseSeriesTransformer): } def __init__(self, max_error=20, transformer="swab", buffer_size=None): - self.transformer = transformer self.max_error = max_error + self.transformer = transformer self.buffer_size = buffer_size super().__init__(axis=0) @@ -256,10 +256,10 @@ def _SWAB(self, X): """ seg_ts = [] if self.buffer_size is None: - self.buffer_size = int(len(X) ** 0.5) + buffer_size = int(len(X) ** 0.5) - lower_boundary_window = int(self.buffer_size / 2) - upper_boundary_window = int(self.buffer_size * 2) + lower_boundary_window = int(buffer_size / 2) + upper_boundary_window = int(buffer_size * 2) seg = self._best_line(X, 0, lower_boundary_window, upper_boundary_window) current_data_point = len(seg) diff --git a/aeon/transformations/series/_siv.py b/aeon/transformations/series/_siv.py index ac511ae0bf..1bb2ad3e0a 100644 --- a/aeon/transformations/series/_siv.py +++ b/aeon/transformations/series/_siv.py @@ -71,16 +71,17 @@ def _transform(self, X, y=None): ------- transformed version of X """ - if self.window_length is None: - self.window_length = [3, 5, 7] - if not isinstance(self.window_length, list): - self.window_length = [self.window_length] + window_length = self.window_length + if window_length is None: + window_length = [3, 5, 7] + if not isinstance(window_length, list): + window_length = [window_length] # Compute SIV X_ = X - for window_length in self.window_length: - footprint = np.ones((1, window_length)) + for w in window_length: + footprint = np.ones((1, w)) X_ = median_filter(X_, footprint=footprint) return X_ From b586e79cc067ee840e347f638362388f5aaaa4b2 Mon Sep 17 00:00:00 2001 From: Tony Bagnall Date: Wed, 27 Nov 2024 13:23:31 +0000 Subject: [PATCH 3/5] fix test exclusions --- aeon/testing/testing_config.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/aeon/testing/testing_config.py b/aeon/testing/testing_config.py index 89893db138..308346621b 100644 --- a/aeon/testing/testing_config.py +++ b/aeon/testing/testing_config.py @@ -57,17 +57,6 @@ "ClaSPSegmenter": ["check_non_state_changing_method"], "HMMSegmenter": ["check_non_state_changing_method"], "BinSegSegmenter": ["check_non_state_changing_method"], - # "QUANTTransformer": ["check_non_state_changing_method"], - # "MatrixProfileSeriesTransformer": ["check_non_state_changing_method"], - # "PLASeriesTransformer": ["check_non_state_changing_method"], - # "AutoCorrelationSeriesTransformer": ["check_non_state_changing_method"], - # "SIVSeriesTransformer": ["check_non_state_changing_method"], - # "RocketClassifier": ["check_non_state_changing_method"], - # "MiniRocketClassifier": ["check_non_state_changing_method"], - # "MultiRocketClassifier": ["check_non_state_changing_method"], - # "RocketRegressor": ["check_non_state_changing_method"], - # "MiniRocketRegressor": ["check_non_state_changing_method"], - # "MultiRocketRegressor": ["check_non_state_changing_method"], "RSTSF": ["check_non_state_changing_method"], # Keeps length during predict to avoid recomputing means and std of data in fit # if the next predict calls uses the same query length parameter. From fb7a163b778d09fb103ccaea987cc15e8093a753 Mon Sep 17 00:00:00 2001 From: Tony Bagnall Date: Wed, 27 Nov 2024 15:02:32 +0000 Subject: [PATCH 4/5] buffer size --- aeon/transformations/series/_pla.py | 1 + 1 file changed, 1 insertion(+) diff --git a/aeon/transformations/series/_pla.py b/aeon/transformations/series/_pla.py index 92fd74e82f..cf1007aa29 100644 --- a/aeon/transformations/series/_pla.py +++ b/aeon/transformations/series/_pla.py @@ -255,6 +255,7 @@ def _SWAB(self, X): List of transformed segmented time series. """ seg_ts = [] + buffer_size = self.buffer_size if self.buffer_size is None: buffer_size = int(len(X) ** 0.5) From 8d42804ac1ce4bcd4d887c4852233498ec8274da Mon Sep 17 00:00:00 2001 From: Tony Bagnall Date: Fri, 29 Nov 2024 14:07:37 +0000 Subject: [PATCH 5/5] stop storing metadata --- aeon/segmentation/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aeon/segmentation/base.py b/aeon/segmentation/base.py index 7a746fd6a3..27517826ae 100644 --- a/aeon/segmentation/base.py +++ b/aeon/segmentation/base.py @@ -116,7 +116,7 @@ def fit(self, X, y=None, axis=1): self.reset() if axis is None: # If none given, assume it is correct. axis = self.axis - X = self._preprocess_series(X, axis, True) + X = self._preprocess_series(X, axis, False) if y is not None: y = self._check_y(y) self._fit(X=X, y=y) @@ -150,7 +150,7 @@ def predict(self, X, axis=1): self._check_is_fitted() if axis is None: axis = self.axis - X = self._preprocess_series(X, axis, self.get_tag("fit_is_empty")) + X = self._preprocess_series(X, axis, False) return self._predict(X) def fit_predict(self, X, y=None, axis=1):