Skip to content

Commit 7b91fff

Browse files
committed
[DOC] Fixed inconsistent backticks in docstrings aeon-toolkit#809
1 parent a2de234 commit 7b91fff

File tree

5 files changed

+160
-131
lines changed

5 files changed

+160
-131
lines changed

aeon/forecasting/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
from aeon.forecasting._dummy import DummyForecaster
1111
from aeon.forecasting._ets import ETSForecaster
1212
from aeon.forecasting._regression import RegressionForecaster
13-
from aeon.forecasting.base import BaseForecaster
13+
from aeon.forecasting.base import BaseForecaster

aeon/forecasting/_dummy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ def _predict(self, y=None, exog=None):
2424
def _forecast(self, y, exog=None):
2525
"""Forecast using dummy forecaster."""
2626
y = y.squeeze()
27-
return y[-1]
27+
return y[-1]

aeon/forecasting/_ets.py

+65-52
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
33
An implementation of the exponential smoothing statistics forecasting algorithm.
44
Implements additive and multiplicative error models,
5-
None, additive and multiplicative (including damped) trend and
6-
None, additive and multiplicative seasonality
5+
``None``, additive, and multiplicative (including damped) trend, and
6+
``None``, additive, and multiplicative seasonality.
77
"""
88

9+
910
__maintainer__ = []
1011
__all__ = ["ETSForecaster", "NONE", "ADDITIVE", "MULTIPLICATIVE"]
1112

@@ -26,30 +27,30 @@ class ETSForecaster(BaseForecaster):
2627
"""Exponential Smoothing forecaster.
2728
2829
An implementation of the exponential smoothing forecasting algorithm.
29-
Implements additive and multiplicative error models, None, additive and
30-
multiplicative (including damped) trend and None, additive and mutliplicative
30+
Implements additive and multiplicative error models, ``None``, additive, and
31+
multiplicative (including damped) trend, and ``None``, additive, and multiplicative
3132
seasonality. See [1]_ for a description.
3233
3334
Parameters
3435
----------
3536
error_type : int, default = 1
36-
Either NONE (0), ADDITIVE (1) or MULTIPLICATIVE (2).
37+
Either ``NONE`` (0), ``ADDITIVE`` (1) or ``MULTIPLICATIVE`` (2).
3738
trend_type : int, default = 0
38-
Either NONE (0), ADDITIVE (1) or MULTIPLICATIVE (2).
39+
Either ``NONE`` (0), ``ADDITIVE`` (1) or ``MULTIPLICATIVE`` (2).
3940
seasonality_type : int, default = 0
40-
Either NONE (0), ADDITIVE (1) or MULTIPLICATIVE (2).
41+
Either ``NONE`` (0), ``ADDITIVE`` (1) or ``MULTIPLICATIVE`` (2).
4142
seasonal_period : int, default=1
42-
Length of seasonality period. If seasonality_type is NONE, this is assumed to
43-
be 1
43+
Length of seasonality period. If ``seasonality_type`` is ``NONE``, this is assumed to
44+
be ``1``.
4445
alpha : float, default = 0.1
4546
Level smoothing parameter.
4647
beta : float, default = 0.01
47-
Trend smoothing parameter. If trend_type is NONE, this is assumed to be 0.0.
48+
Trend smoothing parameter. If ``trend_type`` is ``NONE``, this is assumed to be ``0.0``.
4849
gamma : float, default = 0.01
49-
Seasonal smoothing parameter. If seasonality is NONE, this is assumed to be
50-
0.0.
50+
Seasonal smoothing parameter. If ``seasonality`` is ``NONE``, this is assumed to be
51+
``0.0``.
5152
phi : float, default = 0.99
52-
Trend damping smoothing parameters
53+
Trend damping smoothing parameter.
5354
horizon : int, default = 1
5455
The horizon to forecast to.
5556
@@ -79,7 +80,8 @@ class ETSForecaster(BaseForecaster):
7980
ETSForecaster(alpha=0.4, beta=0.2, gamma=0.5, phi=0.8)
8081
>>> forecaster.predict()
8182
449.9435566831507
82-
"""
83+
"""
84+
8385

8486
def __init__(
8587
self,
@@ -108,22 +110,23 @@ def __init__(
108110
super().__init__(horizon=horizon, axis=1)
109111

110112
def _fit(self, y, exog=None):
111-
"""Fit Exponential Smoothing forecaster to series y.
113+
"""Fit Exponential Smoothing forecaster to series ``y``.
112114
113-
Fit a forecaster to predict self.horizon steps ahead using y.
115+
Fit a forecaster to predict ``self.horizon`` steps ahead using ``y``.
114116
115117
Parameters
116118
----------
117-
y : np.ndarray
118-
A time series on which to learn a forecaster to predict horizon ahead
119-
exog : np.ndarray, default =None
120-
Optional exogenous time series data assumed to be aligned with y
119+
y : ``np.ndarray``
120+
A time series on which to learn a forecaster to predict ``horizon`` ahead.
121+
exog : ``np.ndarray``, default = ``None``
122+
Optional exogenous time series data assumed to be aligned with ``y``.
121123
122124
Returns
123125
-------
124126
self
125-
Fitted BaseForecaster.
127+
Fitted ``BaseForecaster``.
126128
"""
129+
127130
self.n_timepoints_ = len(y)
128131
if self.error_type != MULTIPLICATIVE and self.error_type != ADDITIVE:
129132
raise ValueError("Error must be either additive or multiplicative")
@@ -159,21 +162,22 @@ def _fit(self, y, exog=None):
159162

160163
def _predict(self, y=None, exog=None):
161164
"""
162-
Predict the next horizon steps ahead.
165+
Predict the next ``horizon`` steps ahead.
163166
164167
Parameters
165168
----------
166-
y : np.ndarray, default = None
167-
A time series to predict the next horizon value for. If None,
168-
predict the next horizon value after series seen in fit.
169-
exog : np.ndarray, default = None
170-
Optional exogenous time series data assumed to be aligned with y
169+
y : ``np.ndarray``, default = ``None``
170+
A time series to predict the next ``horizon`` value for. If ``None``,
171+
predict the next ``horizon`` value after series seen in ``fit``.
172+
exog : ``np.ndarray``, default = ``None``
173+
Optional exogenous time series data assumed to be aligned with ``y``.
171174
172175
Returns
173176
-------
174177
float
175-
single prediction self.horizon steps ahead of y.
178+
Single prediction ``self.horizon`` steps ahead of ``y``.
176179
"""
180+
177181
return _predict_numba(
178182
self.trend_type,
179183
self.seasonality_type,
@@ -266,14 +270,22 @@ def _predict_numba(
266270
@njit(nogil=NOGIL, cache=CACHE)
267271
def _initialise(trend_type, seasonality_type, seasonal_period, data):
268272
"""
269-
Initialize level, trend, and seasonality values for the ETS model.
273+
Predict the next ``horizon`` steps ahead.
274+
275+
Parameters
276+
----------
277+
y : ``np.ndarray``, default = ``None``
278+
A time series to predict the next ``horizon`` value for. If ``None``,
279+
predict the next ``horizon`` value after series seen in ``fit``.
280+
exog : ``np.ndarray``, default = ``None``
281+
Optional exogenous time series data assumed to be aligned with ``y``.
282+
283+
Returns
284+
-------
285+
float
286+
Single prediction ``self.horizon`` steps ahead of ``y``.
287+
"""
270288

271-
Parameters
272-
----------
273-
data : array-like
274-
The time series data
275-
(should contain at least two full seasons if seasonality is specified)
276-
"""
277289
# Initial Level: Mean of the first season
278290
level = np.mean(data[:seasonal_period])
279291
# Initial Trend
@@ -326,11 +338,12 @@ def _update_states(
326338
327339
Parameters
328340
----------
329-
data_item: float
341+
data_item : ``float``
330342
The current value of the time series.
331-
seasonal_index: int
343+
seasonal_index : ``int``
332344
The index to update the seasonal component.
333345
"""
346+
334347
# Retrieve the current state values
335348
curr_level = level
336349
curr_seasonality = seasonality
@@ -376,29 +389,29 @@ def _update_states(
376389
@njit(nogil=NOGIL, cache=CACHE)
377390
def _predict_value(trend_type, seasonality_type, level, trend, seasonality, phi):
378391
"""
379-
380392
Generate various useful values, including the next fitted value.
381393
382394
Parameters
383395
----------
384-
trend : float
385-
The current trend value for the model
386-
level : float
387-
The current level value for the model
388-
seasonality : float
389-
The current seasonality value for the model
390-
phi : float
391-
The damping parameter for the model
396+
trend : ``float``
397+
The current trend value for the model.
398+
level : ``float``
399+
The current level value for the model.
400+
seasonality : ``float``
401+
The current seasonality value for the model.
402+
phi : ``float``
403+
The damping parameter for the model.
392404
393405
Returns
394406
-------
395-
fitted_value : float
396-
single prediction based on the current state variables.
397-
damped_trend : float
398-
The damping parameter combined with the trend dependant on the model type
399-
trend_level_combination : float
407+
fitted_value : ``float``
408+
Single prediction based on the current state variables.
409+
damped_trend : ``float``
410+
The damping parameter combined with the trend, dependent on the model type.
411+
trend_level_combination : ``float``
400412
Combination of the trend and level based on the model type.
401413
"""
414+
402415
# Apply damping parameter and
403416
# calculate commonly used combination of trend and level components
404417
if trend_type == MULTIPLICATIVE:
@@ -413,4 +426,4 @@ def _predict_value(trend_type, seasonality_type, level, trend, seasonality, phi)
413426
fitted_value = trend_level_combination * seasonality
414427
else: # Additive seasonality, if no seasonality, then seasonality = 0
415428
fitted_value = trend_level_combination + seasonality
416-
return fitted_value, damped_trend, trend_level_combination
429+
return fitted_value, damped_trend, trend_level_combination

0 commit comments

Comments
 (0)