diff --git a/aeon/segmentation/_binseg.py b/aeon/segmentation/_binseg.py index 6e506aae08..5f3acb6d10 100644 --- a/aeon/segmentation/_binseg.py +++ b/aeon/segmentation/_binseg.py @@ -58,7 +58,9 @@ class BinSegmenter(BaseSegmenter): "python_dependencies": "ruptures", } - def __init__(self, n_cps=1, model="l2", min_size=2, jump=5): + def __init__( + self, n_cps: int = 1, model: str = "l2", min_size: int = 2, jump: int = 5 + ): self.n_cps = n_cps self.model = model self.min_size = min_size @@ -122,7 +124,7 @@ def _get_interval_series(self, X, found_cps): return pd.IntervalIndex.from_arrays(start, end) @classmethod - def _get_test_params(cls, parameter_set="default"): + def _get_test_params(cls, parameter_set: str = "default"): """Return testing parameter settings for the estimator. Parameters diff --git a/aeon/segmentation/_clasp.py b/aeon/segmentation/_clasp.py index 40f5643de0..70df73faba 100644 --- a/aeon/segmentation/_clasp.py +++ b/aeon/segmentation/_clasp.py @@ -4,7 +4,6 @@ __maintainer__ = [] __all__ = ["ClaSPSegmenter", "find_dominant_window_sizes"] - from queue import PriorityQueue import numpy as np @@ -15,7 +14,7 @@ from aeon.utils.validation import check_n_jobs -def find_dominant_window_sizes(X, offset=0.05): +def find_dominant_window_sizes(X, offset: float = 0.05): """Determine the Window-Size using dominant FFT-frequencies. Parameters @@ -55,7 +54,9 @@ def find_dominant_window_sizes(X, offset=0.05): ) -def _is_trivial_match(candidate, change_points, n_timepoints, exclusion_radius=0.05): +def _is_trivial_match( + candidate: int, change_points, n_timepoints: int, exclusion_radius: float = 0.05 +): """Check if a candidate change point is in close proximity to other change points. Parameters @@ -87,7 +88,9 @@ def _is_trivial_match(candidate, change_points, n_timepoints, exclusion_radius=0 return False -def _segmentation(X, clasp, n_change_points=None, exclusion_radius=0.05): +def _segmentation( + X, clasp, n_change_points: int | None = None, exclusion_radius: float = 0.05 +): """Segments the time series by extracting change points. Parameters @@ -182,7 +185,7 @@ class ClaSPSegmenter(BaseSegmenter): Size of window for sliding, based on the period length of the data. n_cps : int, default = 1 The number of change points to search. - exclusion_radius : int + exclusion_radius : float Exclusion Radius for change points to be non-trivial matches. n_jobs : int, default=1 Number of jobs to be used. @@ -209,7 +212,13 @@ class ClaSPSegmenter(BaseSegmenter): _tags = {"capability:multithreading": True, "fit_is_empty": True} - def __init__(self, period_length=10, n_cps=1, exclusion_radius=0.05, n_jobs=1): + def __init__( + self, + period_length: int = 10, + n_cps: int = 1, + exclusion_radius: float = 0.05, + n_jobs: int = 1, + ): self.period_length = int(period_length) self.n_cps = n_cps self.exclusion_radius = exclusion_radius @@ -289,7 +298,7 @@ def _get_interval_series(self, X, found_cps): Parameters ---------- X : array-like, shape = [n] - Univariate time-series data to be segmented. + Univariate time-series data to be segmented. found_cps : array-like, shape = [n_cps] The found change points found Returns @@ -304,7 +313,7 @@ def _get_interval_series(self, X, found_cps): return pd.IntervalIndex.from_arrays(start, end) @classmethod - def _get_test_params(cls, parameter_set="default"): + def _get_test_params(cls, parameter_set: str = "default"): """Return testing parameter settings for the estimator. Parameters diff --git a/aeon/segmentation/_eagglo.py b/aeon/segmentation/_eagglo.py index 1695533f16..fbb46d0723 100644 --- a/aeon/segmentation/_eagglo.py +++ b/aeon/segmentation/_eagglo.py @@ -89,7 +89,7 @@ class EAggloSegmenter(BaseSegmenter): def __init__( self, member=None, - alpha=1.0, + alpha: float = 1.0, penalty=None, ): self.member = member diff --git a/aeon/segmentation/_fluss.py b/aeon/segmentation/_fluss.py index de32b9ed58..3ad566ba81 100644 --- a/aeon/segmentation/_fluss.py +++ b/aeon/segmentation/_fluss.py @@ -48,7 +48,9 @@ class FLUSSSegmenter(BaseSegmenter): "python_dependencies": "stumpy", } - def __init__(self, period_length=10, n_regimes=2, exclusion_factor=5): + def __init__( + self, period_length: int = 10, n_regimes: int = 2, exclusion_factor: int = 5 + ): self.period_length = int(period_length) self.n_regimes = n_regimes self.exclusion_factor = exclusion_factor @@ -137,7 +139,7 @@ def _get_interval_series(self, X, found_cps): return pd.IntervalIndex.from_arrays(start, end) @classmethod - def _get_test_params(cls, parameter_set="default"): + def _get_test_params(cls, parameter_set: str = "default"): """Return testing parameter settings for the estimator. Parameters diff --git a/aeon/segmentation/_random.py b/aeon/segmentation/_random.py index 33ce05b29e..b8c4c80e70 100644 --- a/aeon/segmentation/_random.py +++ b/aeon/segmentation/_random.py @@ -10,7 +10,23 @@ class RandomSegmenter(BaseSegmenter): """Random Segmenter. - Randomly segments a time series. + Randomly segments a time series into a specified number of segments + at random cut points. + + Parameters + ---------- + n_segments : int, default=2 + Number of segments to split the time series into (must be >= 2). + random_state : int, RandomState instance or None, default=None + Random seed for reproducibility. + + Examples + -------- + >>> from aeon.segmentation import RandomSegmenter + >>> segmenter = RandomSegmenter(n_segments=3) + >>> from aeon.testing.data_generation import make_example_1d_numpy + >>> X = make_example_1d_numpy(n_timepoints=100, random_state=0) + >>> found_cps = segmenter.fit_predict(X) """ _tags = { @@ -20,7 +36,7 @@ class RandomSegmenter(BaseSegmenter): "returns_dense": True, } - def __init__(self, random_state=None, n_segments=2): + def __init__(self, random_state=None, n_segments: int = 2): self.random_state = random_state self.breakpoints_ = [] super().__init__(axis=1, n_segments=n_segments)