Skip to content

[DOC] Fixed inconsistent backticks in docstrings #809 #2718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aeon/forecasting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
from aeon.forecasting._dummy import DummyForecaster
from aeon.forecasting._ets import ETSForecaster
from aeon.forecasting._regression import RegressionForecaster
from aeon.forecasting.base import BaseForecaster
from aeon.forecasting.base import BaseForecaster
2 changes: 1 addition & 1 deletion aeon/forecasting/_dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ def _predict(self, y=None, exog=None):
def _forecast(self, y, exog=None):
"""Forecast using dummy forecaster."""
y = y.squeeze()
return y[-1]
return y[-1]
117 changes: 65 additions & 52 deletions aeon/forecasting/_ets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

An implementation of the exponential smoothing statistics forecasting algorithm.
Implements additive and multiplicative error models,
None, additive and multiplicative (including damped) trend and
None, additive and multiplicative seasonality
``None``, additive, and multiplicative (including damped) trend, and
``None``, additive, and multiplicative seasonality.
"""


__maintainer__ = []
__all__ = ["ETSForecaster", "NONE", "ADDITIVE", "MULTIPLICATIVE"]

Expand All @@ -26,30 +27,30 @@ class ETSForecaster(BaseForecaster):
"""Exponential Smoothing forecaster.

An implementation of the exponential smoothing forecasting algorithm.
Implements additive and multiplicative error models, None, additive and
multiplicative (including damped) trend and None, additive and mutliplicative
Implements additive and multiplicative error models, ``None``, additive, and
multiplicative (including damped) trend, and ``None``, additive, and multiplicative
seasonality. See [1]_ for a description.

Parameters
----------
error_type : int, default = 1
Either NONE (0), ADDITIVE (1) or MULTIPLICATIVE (2).
Either ``NONE`` (0), ``ADDITIVE`` (1) or ``MULTIPLICATIVE`` (2).
trend_type : int, default = 0
Either NONE (0), ADDITIVE (1) or MULTIPLICATIVE (2).
Either ``NONE`` (0), ``ADDITIVE`` (1) or ``MULTIPLICATIVE`` (2).
seasonality_type : int, default = 0
Either NONE (0), ADDITIVE (1) or MULTIPLICATIVE (2).
Either ``NONE`` (0), ``ADDITIVE`` (1) or ``MULTIPLICATIVE`` (2).
seasonal_period : int, default=1
Length of seasonality period. If seasonality_type is NONE, this is assumed to
be 1
Length of seasonality period. If ``seasonality_type`` is ``NONE``, this is assumed to
be ``1``.
alpha : float, default = 0.1
Level smoothing parameter.
beta : float, default = 0.01
Trend smoothing parameter. If trend_type is NONE, this is assumed to be 0.0.
Trend smoothing parameter. If ``trend_type`` is ``NONE``, this is assumed to be ``0.0``.
gamma : float, default = 0.01
Seasonal smoothing parameter. If seasonality is NONE, this is assumed to be
0.0.
Seasonal smoothing parameter. If ``seasonality`` is ``NONE``, this is assumed to be
``0.0``.
phi : float, default = 0.99
Trend damping smoothing parameters
Trend damping smoothing parameter.
horizon : int, default = 1
The horizon to forecast to.

Expand Down Expand Up @@ -79,7 +80,8 @@ class ETSForecaster(BaseForecaster):
ETSForecaster(alpha=0.4, beta=0.2, gamma=0.5, phi=0.8)
>>> forecaster.predict()
449.9435566831507
"""
"""


def __init__(
self,
Expand Down Expand Up @@ -108,22 +110,23 @@ def __init__(
super().__init__(horizon=horizon, axis=1)

def _fit(self, y, exog=None):
"""Fit Exponential Smoothing forecaster to series y.
"""Fit Exponential Smoothing forecaster to series ``y``.

Fit a forecaster to predict self.horizon steps ahead using y.
Fit a forecaster to predict ``self.horizon`` steps ahead using ``y``.

Parameters
----------
y : np.ndarray
A time series on which to learn a forecaster to predict horizon ahead
exog : np.ndarray, default =None
Optional exogenous time series data assumed to be aligned with y
y : ``np.ndarray``
A time series on which to learn a forecaster to predict ``horizon`` ahead.
exog : ``np.ndarray``, default = ``None``
Optional exogenous time series data assumed to be aligned with ``y``.

Returns
-------
self
Fitted BaseForecaster.
Fitted ``BaseForecaster``.
"""

self.n_timepoints_ = len(y)
if self.error_type != MULTIPLICATIVE and self.error_type != ADDITIVE:
raise ValueError("Error must be either additive or multiplicative")
Expand Down Expand Up @@ -159,21 +162,22 @@ def _fit(self, y, exog=None):

def _predict(self, y=None, exog=None):
"""
Predict the next horizon steps ahead.
Predict the next ``horizon`` steps ahead.

Parameters
----------
y : np.ndarray, default = None
A time series to predict the next horizon value for. If None,
predict the next horizon value after series seen in fit.
exog : np.ndarray, default = None
Optional exogenous time series data assumed to be aligned with y
y : ``np.ndarray``, default = ``None``
A time series to predict the next ``horizon`` value for. If ``None``,
predict the next ``horizon`` value after series seen in ``fit``.
exog : ``np.ndarray``, default = ``None``
Optional exogenous time series data assumed to be aligned with ``y``.

Returns
-------
float
single prediction self.horizon steps ahead of y.
Single prediction ``self.horizon`` steps ahead of ``y``.
"""

return _predict_numba(
self.trend_type,
self.seasonality_type,
Expand Down Expand Up @@ -266,14 +270,22 @@ def _predict_numba(
@njit(nogil=NOGIL, cache=CACHE)
def _initialise(trend_type, seasonality_type, seasonal_period, data):
"""
Initialize level, trend, and seasonality values for the ETS model.
Predict the next ``horizon`` steps ahead.

Parameters
----------
y : ``np.ndarray``, default = ``None``
A time series to predict the next ``horizon`` value for. If ``None``,
predict the next ``horizon`` value after series seen in ``fit``.
exog : ``np.ndarray``, default = ``None``
Optional exogenous time series data assumed to be aligned with ``y``.

Returns
-------
float
Single prediction ``self.horizon`` steps ahead of ``y``.
"""

Parameters
----------
data : array-like
The time series data
(should contain at least two full seasons if seasonality is specified)
"""
# Initial Level: Mean of the first season
level = np.mean(data[:seasonal_period])
# Initial Trend
Expand Down Expand Up @@ -326,11 +338,12 @@ def _update_states(

Parameters
----------
data_item: float
data_item : ``float``
The current value of the time series.
seasonal_index: int
seasonal_index : ``int``
The index to update the seasonal component.
"""

# Retrieve the current state values
curr_level = level
curr_seasonality = seasonality
Expand Down Expand Up @@ -376,29 +389,29 @@ def _update_states(
@njit(nogil=NOGIL, cache=CACHE)
def _predict_value(trend_type, seasonality_type, level, trend, seasonality, phi):
"""

Generate various useful values, including the next fitted value.

Parameters
----------
trend : float
The current trend value for the model
level : float
The current level value for the model
seasonality : float
The current seasonality value for the model
phi : float
The damping parameter for the model
trend : ``float``
The current trend value for the model.
level : ``float``
The current level value for the model.
seasonality : ``float``
The current seasonality value for the model.
phi : ``float``
The damping parameter for the model.

Returns
-------
fitted_value : float
single prediction based on the current state variables.
damped_trend : float
The damping parameter combined with the trend dependant on the model type
trend_level_combination : float
fitted_value : ``float``
Single prediction based on the current state variables.
damped_trend : ``float``
The damping parameter combined with the trend, dependent on the model type.
trend_level_combination : ``float``
Combination of the trend and level based on the model type.
"""

# Apply damping parameter and
# calculate commonly used combination of trend and level components
if trend_type == MULTIPLICATIVE:
Expand All @@ -413,4 +426,4 @@ def _predict_value(trend_type, seasonality_type, level, trend, seasonality, phi)
fitted_value = trend_level_combination * seasonality
else: # Additive seasonality, if no seasonality, then seasonality = 0
fitted_value = trend_level_combination + seasonality
return fitted_value, damped_trend, trend_level_combination
return fitted_value, damped_trend, trend_level_combination
Loading
Loading