From 8031c8c313da00def4b8bddf4332a6b750438156 Mon Sep 17 00:00:00 2001 From: Egor Baturin <82458209+egoriyaa@users.noreply.github.com> Date: Fri, 31 Jan 2025 13:06:50 +0300 Subject: [PATCH] Remove parameters `freq` and `dates` from statsmodels-base models (#590) * remove freq and dates attributes * lints * update changelog * lints * return filterwarning to script --------- Co-authored-by: Egor Baturin --- CHANGELOG.md | 2 +- etna/models/holt_winters.py | 25 ------------------------- etna/models/sarimax.py | 25 ------------------------- pyproject.toml | 3 --- 4 files changed, 1 insertion(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3b436682..0dfc1447b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,7 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed - **Breaking:** Remove `FutureMixin`, `OutliersTransform.outliers_timestamps` and `OutliersTransform.original_values` ([#577](https://github.com/etna-team/etna/pull/577)) -- +- **Breaking:** Remove parameters `freq` and `dates` from `SARIMAXModel` and `HoltWintersModel` ([#590](https://github.com/etna-team/etna/pull/590)) - **Breaking:** Remove `pytorch-forecasting` models and utilities (`DeepARModel`, `TFTModel` and `PytorchForecastingDatasetBuilder`) ([#578](https://github.com/etna-team/etna/pull/578)) - - diff --git a/etna/models/holt_winters.py b/etna/models/holt_winters.py index c0df7508a..ed064e817 100644 --- a/etna/models/holt_winters.py +++ b/etna/models/holt_winters.py @@ -1,5 +1,4 @@ import warnings -from datetime import datetime from typing import Dict from typing import List from typing import Optional @@ -47,8 +46,6 @@ def __init__( initial_seasonal: Optional[Sequence[float]] = None, use_boxcox: Union[bool, str, float] = False, bounds: Optional[Dict[str, Tuple[float, float]]] = None, - dates: Optional[Sequence[datetime]] = None, - freq: Optional[str] = None, missing: str = "none", smoothing_level: Optional[float] = None, smoothing_trend: Optional[float] = None, @@ -152,12 +149,6 @@ def __init__( for j=0,...,m-1 where m is the number of period in a full season. Use None to indicate a non-binding constraint, e.g., (0, None) constrains a parameter to be non-negative. - dates: - An array-like object of datetime objects. If a Pandas object is given - for endog, it is assumed to have a DateIndex. - freq: - The frequency of the time-series. A Pandas offset or 'B', 'D', 'W', - 'M', 'A', or 'Q'. This is optional if dates are given. missing: Available options are 'none', 'drop', and 'raise'. If 'none', no nan checking is done. If 'drop', any observations with nans are dropped. @@ -187,8 +178,6 @@ def __init__( self.initial_seasonal = initial_seasonal self.use_boxcox = use_boxcox self.bounds = bounds - self.dates = dates - self.freq = freq self.missing = missing self.smoothing_level = smoothing_level self.smoothing_trend = smoothing_trend @@ -251,8 +240,6 @@ def fit(self, df: pd.DataFrame, regressors: List[str]) -> "_HoltWintersAdapter": initial_seasonal=self.initial_seasonal, use_boxcox=self.use_boxcox, bounds=self.bounds, - dates=self.dates, - freq=self.freq, missing=self.missing, ) self._result = self._model.fit( @@ -495,8 +482,6 @@ def __init__( initial_seasonal: Optional[Sequence[float]] = None, use_boxcox: Union[bool, str, float] = False, bounds: Optional[Dict[str, Tuple[float, float]]] = None, - dates: Optional[Sequence[datetime]] = None, - freq: Optional[str] = None, missing: str = "none", smoothing_level: Optional[float] = None, smoothing_trend: Optional[float] = None, @@ -600,12 +585,6 @@ def __init__( for j=0,...,m-1 where m is the number of period in a full season. Use None to indicate a non-binding constraint, e.g., (0, None) constrains a parameter to be non-negative. - dates: - An array-like object of datetime objects. If a Pandas object is given - for endog, it is assumed to have a DateIndex. - freq: - The frequency of the time-series. A Pandas offset or 'B', 'D', 'W', - 'M', 'A', or 'Q'. This is optional if dates are given. missing: Available options are 'none', 'drop', and 'raise'. If 'none', no nan checking is done. If 'drop', any observations with nans are dropped. @@ -635,8 +614,6 @@ def __init__( self.initial_seasonal = initial_seasonal self.use_boxcox = use_boxcox self.bounds = bounds - self.dates = dates - self.freq = freq self.missing = missing self.smoothing_level = smoothing_level self.smoothing_trend = smoothing_trend @@ -655,8 +632,6 @@ def __init__( initial_seasonal=self.initial_seasonal, use_boxcox=self.use_boxcox, bounds=self.bounds, - dates=self.dates, - freq=self.freq, missing=self.missing, smoothing_level=self.smoothing_level, smoothing_trend=self.smoothing_trend, diff --git a/etna/models/sarimax.py b/etna/models/sarimax.py index 4bc53136b..e517028f7 100644 --- a/etna/models/sarimax.py +++ b/etna/models/sarimax.py @@ -1,6 +1,5 @@ import warnings from abc import abstractmethod -from datetime import datetime from typing import Any from typing import Dict from typing import List @@ -456,8 +455,6 @@ def __init__( concentrate_scale: bool = False, trend_offset: float = 1, use_exact_diffuse: bool = False, - dates: Optional[List[datetime]] = None, - freq: Optional[str] = None, missing: str = "none", validate_specification: bool = True, fit_params: Optional[Dict[str, Any]] = None, @@ -537,12 +534,6 @@ def __init__( Whether or not to use exact diffuse initialization for non-stationary states. Default is False (in which case approximate diffuse initialization is used). - dates: - If no index is given by `endog` or `exog`, an array-like object of - datetime objects can be provided. - freq: - If no index is given by `endog` or `exog`, the frequency of the - time-series may be specified here as a Pandas offset or offset string. missing: Available options are 'none', 'drop', and 'raise'. If 'none', no nan checking is done. If 'drop', any observations with nans are dropped. @@ -568,8 +559,6 @@ def __init__( self.concentrate_scale = concentrate_scale self.trend_offset = trend_offset self.use_exact_diffuse = use_exact_diffuse - self.dates = dates - self.freq = freq self.missing = missing self.validate_specification = validate_specification self.fit_params = fit_params if fit_params else {} @@ -595,8 +584,6 @@ def _get_fit_results(self, endog: pd.Series, exog: pd.DataFrame): concentrate_scale=self.concentrate_scale, trend_offset=self.trend_offset, use_exact_diffuse=self.use_exact_diffuse, - dates=self.dates, - freq=self.freq, missing=self.missing, validate_specification=self.validate_specification, **self.kwargs, @@ -641,8 +628,6 @@ def __init__( concentrate_scale: bool = False, trend_offset: float = 1, use_exact_diffuse: bool = False, - dates: Optional[List[datetime]] = None, - freq: Optional[str] = None, missing: str = "none", validate_specification: bool = True, fit_params: Optional[Dict[str, Any]] = None, @@ -722,12 +707,6 @@ def __init__( Whether or not to use exact diffuse initialization for non-stationary states. Default is False (in which case approximate diffuse initialization is used). - dates: - If no index is given by `endog` or `exog`, an array-like object of - datetime objects can be provided. - freq: - If no index is given by `endog` or `exog`, the frequency of the - time-series may be specified here as a Pandas offset or offset string. missing: Available options are 'none', 'drop', and 'raise'. If 'none', no nan checking is done. If 'drop', any observations with nans are dropped. @@ -753,8 +732,6 @@ def __init__( self.concentrate_scale = concentrate_scale self.trend_offset = trend_offset self.use_exact_diffuse = use_exact_diffuse - self.dates = dates - self.freq = freq self.missing = missing self.validate_specification = validate_specification self.fit_params = fit_params if fit_params else {} @@ -774,8 +751,6 @@ def __init__( concentrate_scale=self.concentrate_scale, trend_offset=self.trend_offset, use_exact_diffuse=self.use_exact_diffuse, - dates=self.dates, - freq=self.freq, missing=self.missing, validate_specification=self.validate_specification, fit_params=self.fit_params, diff --git a/pyproject.toml b/pyproject.toml index 5380e987d..7f7fc718c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -263,11 +263,8 @@ filterwarnings = [ "ignore: The behavior of Timestamp.utcfromtimestamp is deprecated", # prophet "ignore: Starting from v1.9.0, `tensorboardX` has been removed as a dependency", "ignore: the `interpolation=` argument to percentile was renamed to `method=`", # pandas: old version uses deprecated numpy parameter - "ignore: Trying to infer the `batch_size` from an ambiguous collection", # pytorch_forecasting "ignore: Implicitly cleaning up