Skip to content

Commit

Permalink
Pull from origin
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdivya1309 committed Jun 24, 2024
2 parents 67f9284 + 156368e commit b5e9fed
Show file tree
Hide file tree
Showing 35 changed files with 294 additions and 1,897 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/pr_precommit.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: PR pre-commit

on:
push:
branches:
- main
pull_request_target:
branches:
- main
Expand All @@ -27,7 +24,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ steps.app-token.outputs.token }}

- name: Setup Python 3.10
Expand Down
9 changes: 8 additions & 1 deletion aeon/anomaly_detection/_merlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MERLIN(BaseAnomalyDetector):
"""MERLIN anomaly detector.
MERLIN is a discord discovery algorithm that uses a sliding window to find the
most anomalous subsequence in a time series. The algorithm is based on the
most anomalous subsequence in a time series [1]_. The algorithm is based on the
Euclidean distance between subsequences of the time series.
.. list-table:: Capabilities
Expand All @@ -43,6 +43,13 @@ class MERLIN(BaseAnomalyDetector):
length. If no anomaly is found, the algorithm will move to the next length
and reset ``r``.
References
----------
.. [1] Nakamura, M. Imamura, R. Mercer and E. Keogh, "MERLIN: Parameter-Free
Discovery of Arbitrary Length Anomalies in Massive Time Series
Archives," 2020 IEEE International Conference on Data Mining (ICDM),
Sorrento, Italy, 2020, pp. 1190-1195.
Examples
--------
>>> import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions aeon/datasets/_data_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ def write_to_tsfile(
Write metadata and data stored in aeon compatible data set to file.
A description of the ts format is in examples/load_data.ipynb.
Note that this file is structured to still support the
Parameters
----------
X : np.ndarray (n_cases, n_channels, n_timepoints) or list of np.ndarray[
Expand Down
5 changes: 2 additions & 3 deletions aeon/forecasting/compose/_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,7 @@ class TransformedTargetForecaster(_Pipeline):
... ("detrender", Detrender()),
... ("forecaster", NaiveForecaster(strategy="drift")),
... ])
>>> pipe.fit(y)
TransformedTargetForecaster(...)
>>> t = pipe.fit(y)
>>> y_pred = pipe.predict(fh=[1,2,3])
Example 2: without strings
Expand Down Expand Up @@ -1558,7 +1557,7 @@ class Permute(_DelegatedForecaster, BaseForecaster, _HeterogenousMetaEstimator):
>>> from aeon.forecasting.base import ForecastingHorizon
>>> from aeon.forecasting.compose import ForecastingPipeline, Permute
>>> from aeon.forecasting.naive import NaiveForecaster
>>> from aeon.transformations.boxcox import BoxCoxTransformer
>>> from aeon.transformations.series._boxcox import BoxCoxTransformer
>>> from aeon.transformations.exponent import ExponentTransformer
Simple example: permute sequence of estimator in forecasting pipeline
Expand Down
6 changes: 3 additions & 3 deletions aeon/forecasting/compose/tests/test_bagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from aeon.forecasting.compose import BaggingForecaster
from aeon.forecasting.compose._bagging import _calculate_data_quantiles
from aeon.forecasting.naive import NaiveForecaster
from aeon.transformations._legacy._boxcox import _LogTransformer
from aeon.transformations.bootstrap import STLBootstrapTransformer
from aeon.transformations.boxcox import LogTransformer
from aeon.utils.validation._dependencies import _check_soft_dependencies

y = load_airline()
Expand All @@ -18,7 +18,7 @@
not _check_soft_dependencies("statsmodels", severity="none"),
reason="skip test if required soft dependency for BaggingForecaster not available",
)
@pytest.mark.parametrize("transformer", [LogTransformer, NaiveForecaster])
@pytest.mark.parametrize("transformer", [_LogTransformer, NaiveForecaster])
def test_bagging_forecaster_transformer_type_error(transformer):
"""Test that the right exception is raised for invalid transformer."""
with pytest.raises(TypeError) as ex:
Expand All @@ -37,7 +37,7 @@ def test_bagging_forecaster_transformer_type_error(transformer):
not _check_soft_dependencies("statsmodels", severity="none"),
reason="skip test if required soft dependency not available",
)
@pytest.mark.parametrize("forecaster", [LogTransformer])
@pytest.mark.parametrize("forecaster", [_LogTransformer])
def test_bagging_forecaster_forecaster_type_error(forecaster):
"""Test that the right exception is raised for invalid forecaster."""
with pytest.raises(TypeError) as ex:
Expand Down
2 changes: 1 addition & 1 deletion aeon/forecasting/compose/tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_nesting_pipelines():
from aeon.testing.utils.scenarios_forecasting import (
ForecasterFitPredictUnivariateWithX,
)
from aeon.transformations.boxcox import LogTransformer
from aeon.transformations._legacy._boxcox import _LogTransformer as LogTransformer
from aeon.transformations.compose import OptionalPassthrough
from aeon.transformations.detrend import Detrender

Expand Down
15 changes: 10 additions & 5 deletions aeon/segmentation/_clasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pandas as pd

from aeon.segmentation.base import BaseSegmenter
from aeon.transformations.clasp import ClaSPTransformer
from aeon.transformations.series import ClaSPTransformer


def find_dominant_window_sizes(X, offset=0.05):
Expand Down Expand Up @@ -66,7 +66,7 @@ def _is_trivial_match(candidate, change_points, n_timepoints, exclusion_radius=0
List of change points chosen so far
n_timepoints : int
Total length
exclusion_radius : int
exclusion_radius : float
Exclusion Radius for change points to be non-trivial matches
Returns
Expand Down Expand Up @@ -97,7 +97,7 @@ def _segmentation(X, clasp, n_change_points=None, exclusion_radius=0.05):
the transformer
n_change_points : int
the number of change points to find
exclusion_radius :
exclusion_radius : float
the exclusion zone
Returns
Expand Down Expand Up @@ -183,6 +183,8 @@ class ClaSPSegmenter(BaseSegmenter):
The number of change points to search.
exclusion_radius : int
Exclusion Radius for change points to be non-trivial matches.
n_jobs : int, default=1
Number of jobs to be used.
References
----------
Expand All @@ -206,10 +208,11 @@ class ClaSPSegmenter(BaseSegmenter):

_tags = {"fit_is_empty": True} # for unit test cases

def __init__(self, period_length=10, n_cps=1, exclusion_radius=0.05):
def __init__(self, period_length=10, n_cps=1, exclusion_radius=0.05, n_jobs=1):
self.period_length = int(period_length)
self.n_cps = n_cps
self.exclusion_radius = exclusion_radius
self.n_jobs = n_jobs
super().__init__(axis=1, n_segments=n_cps + 1)

def _predict(self, X: np.ndarray):
Expand Down Expand Up @@ -263,7 +266,9 @@ def get_fitted_params(self):

def _run_clasp(self, X):
clasp_transformer = ClaSPTransformer(
window_length=self.period_length, exclusion_radius=self.exclusion_radius
window_length=self.period_length,
exclusion_radius=self.exclusion_radius,
n_jobs=self.n_jobs,
).fit(X)

self.found_cps, self.profiles, self.scores = _segmentation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)
from aeon.testing.utils.deep_equals import deep_equals
from aeon.transformations.base import BaseTransformer
from aeon.transformations.boxcox import BoxCoxTransformer
from aeon.transformations.series._boxcox import BoxCoxTransformer

y_series = load_airline().iloc[:-5]
y_frame = y_series.to_frame()
Expand Down
4 changes: 2 additions & 2 deletions aeon/testing/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import aeon.testing.utils._cicd_numba_caching # noqa: F401

EXCLUDE_ESTIMATORS = [
"BoxCoxTransformer",
"_BoxCoxTransformer",
"TimeBinAggregate",
"PartialAutoCorrelationTransformer",
"LogTransformer",
"_LogTransformer",
"ReverseAugmenter",
"RandomSamplesAugmenter",
"SqrtTransformer",
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""Implemenents Box-Cox and Log Transformations."""

__maintainer__ = []
__all__ = ["BoxCoxTransformer", "LogTransformer"]
__all__ = ["_BoxCoxTransformer", "_LogTransformer"]

import numpy as np
from deprecated.sphinx import deprecated
from scipy import optimize, special, stats
from scipy.special import boxcox, inv_boxcox
from scipy.stats import boxcox_llf, distributions, variation
Expand Down Expand Up @@ -41,21 +40,14 @@ def _calc_uniform_order_statistic_medians(n):
return v


# TODO: remove in v0.10.0
@deprecated(
version="0.9.0",
reason="BoxCoxTransformer will be removed in version 0.10.0 and replaced with a "
"BaseSeriesTransformer version in the transformations.series module.",
category=FutureWarning,
)
class BoxCoxTransformer(BaseTransformer):
class _BoxCoxTransformer(BaseTransformer):
r"""Box-Cox power transform.
Box-Cox transformation is a power transformation that is used to
make data more normally distributed and stabilize its variance based
on the hyperparameter lambda. [1]_
The BoxCoxTransformer solves for the lambda parameter used in the Box-Cox
The _BoxCoxTransformer solves for the lambda parameter used in the Box-Cox
transformation given `method`, the optimization approach, and input
data provided to `fit`. The use of Guerrero's method for solving for lambda
requires the seasonal periodicity, `sp` be provided. [2]_
Expand Down Expand Up @@ -88,7 +80,7 @@ class BoxCoxTransformer(BaseTransformer):
See Also
--------
LogTransformer :
_LogTransformer :
Transformer input data using natural log. Can help normalize data and
compress variance of the series.
aeon.transformations.exponent.ExponentTransformer :
Expand All @@ -113,14 +105,6 @@ class BoxCoxTransformer(BaseTransformer):
Journal ofthe Royal Statistical Society, Series B, 26, 211-252.
.. [2] V.M. Guerrero, "Time-series analysis supported by Power
Transformations ", Journal of Forecasting, vol. 12, pp. 37-48, 1993.
Examples
--------
>>> from aeon.transformations.boxcox import BoxCoxTransformer
>>> from aeon.datasets import load_airline
>>> y = load_airline()
>>> transformer = BoxCoxTransformer()
>>> y_hat = transformer.fit_transform(y)
"""

_tags = {
Expand Down Expand Up @@ -214,14 +198,7 @@ def _inverse_transform(self, X, y=None):
return Xt


# TODO: remove in v0.10.0
@deprecated(
version="0.9.0",
reason="LogTransformer will be removed in version 0.10.0 and replaced with a "
"BaseSeriesTransformer version in the transformations.series module.",
category=FutureWarning,
)
class LogTransformer(BaseTransformer):
class _LogTransformer(BaseTransformer):
"""Natural logarithm transformation.
The Natural logarithm transformation can be used to make the data more normally
Expand All @@ -238,7 +215,7 @@ class LogTransformer(BaseTransformer):
See Also
--------
BoxCoxTransformer :
_BoxCoxTransformer :
Applies Box-Cox power transformation. Can help normalize data and
compress variance of the series.
aeon.transformations.exponent.ExponentTransformer :
Expand All @@ -251,14 +228,6 @@ class LogTransformer(BaseTransformer):
Notes
-----
The log transformation is applied as :math:`ln(y)`.
Examples
--------
>>> from aeon.transformations.boxcox import LogTransformer
>>> from aeon.datasets import load_airline
>>> y = load_airline()
>>> transformer = LogTransformer()
>>> y_hat = transformer.fit_transform(y)
"""

_tags = {
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion aeon/transformations/adapt.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def get_test_params(cls, parameter_set="default"):
# TODO: remove in v0.11.0
@deprecated(
version="0.10.0",
reason="PandasTransformAdaptorwill be removed in version 0.11.0.",
reason="PandasTransformAdaptor will be removed in version 0.11.0.",
category=FutureWarning,
)
class PandasTransformAdaptor(BaseTransformer):
Expand Down
17 changes: 15 additions & 2 deletions aeon/transformations/bootstrap/_mbb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@

import numpy as np
import pandas as pd
from deprecated.sphinx import deprecated
from sklearn.utils import check_random_state

from aeon.transformations._legacy._boxcox import _BoxCoxTransformer
from aeon.transformations.base import BaseTransformer
from aeon.transformations.boxcox import BoxCoxTransformer


# TODO: remove in v0.11.0
@deprecated(
version="0.10.0",
reason="STLBootstrapTransformer will be removed in version 0.11.0.",
category=FutureWarning,
)
class STLBootstrapTransformer(BaseTransformer):
"""Creates a population of similar time series.
Expand Down Expand Up @@ -265,7 +272,7 @@ def _fit(self, X, y=None):
)

# fit boxcox to get lambda and transform X
self.box_cox_transformer_ = BoxCoxTransformer(
self.box_cox_transformer_ = _BoxCoxTransformer(
sp=self.sp, bounds=self.lambda_bounds, method=self.lambda_method
)
self.box_cox_transformer_.fit(X)
Expand Down Expand Up @@ -399,6 +406,12 @@ def get_test_params(cls, parameter_set="default"):
return params


# TODO: remove in v0.11.0
@deprecated(
version="0.10.0",
reason="MovingBlockBootstrapTransformer will be removed in version 0.11.0.",
category=FutureWarning,
)
class MovingBlockBootstrapTransformer(BaseTransformer):
"""Moving Block Bootstrapping method for synthetic time series generation.
Expand Down
Loading

0 comments on commit b5e9fed

Please sign in to comment.