Skip to content

Commit

Permalink
[DEP] Move impute to legacy (#1823)
Browse files Browse the repository at this point in the history
* impute to legacy

* remove imputer API

* remove Theta

* fix import
  • Loading branch information
TonyBagnall authored Aug 4, 2024
1 parent f523a27 commit cbd1e4a
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 176 deletions.
2 changes: 1 addition & 1 deletion aeon/classification/hybrid/_hivecote_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
representations, using the weighted probabilistic CAWPE as an ensemble controller.
"""

__maintainer__ = []
__maintainer__ = ["MatthewMiddlehurst", "TonyBagnall"]
__all__ = ["HIVECOTEV2"]

from datetime import datetime
Expand Down
62 changes: 0 additions & 62 deletions aeon/forecasting/model_selection/_tune.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,68 +386,6 @@ class ForecastingGridSearchCV(BaseGridSearch):
n_best_scores_: list of float
The scores of n_best_forecasters_ sorted from best to worst
score of forecasters
Examples
--------
>>> from aeon.datasets import load_shampoo_sales
>>> from aeon.forecasting.model_selection import (
... ExpandingWindowSplitter,
... ForecastingGridSearchCV,
... ExpandingWindowSplitter)
>>> from aeon.forecasting.naive import NaiveForecaster
>>> y = load_shampoo_sales()
>>> fh = [1,2,3]
>>> cv = ExpandingWindowSplitter(fh=fh)
>>> forecaster = NaiveForecaster()
>>> param_grid = {"strategy" : ["last", "mean", "drift"]}
>>> gscv = ForecastingGridSearchCV(
... forecaster=forecaster,
... param_grid=param_grid,
... cv=cv,
... n_jobs=-1)
>>> gscv.fit(y)
ForecastingGridSearchCV(...)
>>> y_pred = gscv.predict(fh)
Advanced model meta-tuning (model selection) with multiple forecasters
together with hyper-parametertuning at same time using sklearn notation:
>>> from aeon.datasets import load_shampoo_sales
>>> from aeon.forecasting.exp_smoothing import ExponentialSmoothing
>>> from aeon.forecasting.naive import NaiveForecaster
>>> from aeon.forecasting.model_selection import ExpandingWindowSplitter
>>> from aeon.forecasting.model_selection import ForecastingGridSearchCV
>>> from aeon.forecasting.compose import TransformedTargetForecaster
>>> from aeon.forecasting.theta import ThetaForecaster
>>> from aeon.transformations.impute import Imputer
>>> y = load_shampoo_sales()
>>> pipe = TransformedTargetForecaster(steps=[
... ("imputer", Imputer()),
... ("forecaster", NaiveForecaster())])
>>> cv = ExpandingWindowSplitter(
... initial_window=24,
... step_length=12,
... fh=[1,2,3])
>>> gscv = ForecastingGridSearchCV(
... forecaster=pipe,
... param_grid=[{
... "forecaster": [NaiveForecaster(sp=12)],
... "forecaster__strategy": ["drift", "last", "mean"],
... },
... {
... "imputer__method": ["mean", "drift"],
... "forecaster": [ThetaForecaster(sp=12)],
... },
... {
... "imputer__method": ["mean", "median"],
... "forecaster": [ExponentialSmoothing(sp=12)],
... "forecaster__trend": ["add", "mul"],
... },
... ],
... cv=cv,
... n_jobs=-1) # doctest: +SKIP
>>> gscv.fit(y) # doctest: +SKIP
ForecastingGridSearchCV(...)
>>> y_pred = gscv.predict(fh=[1,2,3]) # doctest: +SKIP
"""

def __init__(
Expand Down
2 changes: 1 addition & 1 deletion aeon/transformations/_legacy/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ def get_test_params(cls, parameter_set="default"):
-------
params : dict or list of dict
"""
from aeon.transformations.impute import Imputer
from aeon.transformations._legacy.impute import Imputer

# test with 2 simple detrend transformations with selected_transformer
params1 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,13 @@


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

from aeon.forecasting.base import ForecastingHorizon
from aeon.forecasting.trend import PolynomialTrendForecaster
from aeon.transformations.base import BaseTransformer


# TODO: remove in v0.11.0
@deprecated(
version="0.10.0",
reason="Imputer will be removed in version 0.11.0.",
category=FutureWarning,
)
class Imputer(BaseTransformer):
"""Missing value imputation.
Expand Down Expand Up @@ -70,19 +63,6 @@ class Imputer(BaseTransformer):
method="forecaster" is set, otherwise forecaster is ignored.
random_state : int/float/str, optional
Value to set random.seed() if method="random", default None
Examples
--------
>>> from aeon.transformations.impute import Imputer
>>> from aeon.datasets import load_airline
>>> from aeon.forecasting.model_selection import temporal_train_test_split
>>> y = load_airline()
>>> y_train, y_test = temporal_train_test_split(y)
>>> transformer = Imputer(method="drift")
>>> transformer.fit(y_train)
Imputer(...)
>>> y_test.iloc[3] = np.nan
>>> y_hat = transformer.transform(y_test)
"""

_tags = {
Expand Down
2 changes: 1 addition & 1 deletion aeon/transformations/_legacy/lag.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def _fit(self, X, y=None):
self: reference to self
"""
from aeon.transformations._legacy.compose import FeatureUnion, YtoX
from aeon.transformations.impute import Imputer
from aeon.transformations._legacy.impute import Imputer

impute_method = self.impute_method
lags = self._lags
Expand Down
2 changes: 1 addition & 1 deletion aeon/transformations/tests/test_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
OptionalPassthrough,
TransformerPipeline,
)
from aeon.transformations._legacy.impute import Imputer
from aeon.transformations._legacy.subset import _ColumnSelect
from aeon.transformations._legacy.summarize import SummaryTransformer
from aeon.transformations._legacy.theta import (
_ThetaLinesTransformer as ThetaLinesTransformer,
)
from aeon.transformations.collection.pad import PaddingTransformer
from aeon.transformations.impute import Imputer


def test_dunder_mul():
Expand Down
78 changes: 0 additions & 78 deletions aeon/transformations/tests/test_imputer.py

This file was deleted.

12 changes: 0 additions & 12 deletions docs/api_reference/transformations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,6 @@ Segmentation
RandomIntervalSegmenter
SlidingWindowSegmenter

Missing value imputation
~~~~~~~~~~~~~~~~~~~~~~~~

.. currentmodule:: aeon.transformations.impute

.. autosummary::
:toctree: auto_generated/
:template: class.rst

Imputer


Window-based series transforms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit cbd1e4a

Please sign in to comment.