Repository: aeon-toolkit/aeon
Pull request #2831 (2025-05-23 10:19:02)

[ENH] refactor dummy forecaster to naive
simple refactor, part of https://github.com/aeon-toolkit/aeon/issues/2823



review-notebook-app[bot]: Check out this pull request on&nbsp; <a href="https://app.reviewnb.com/aeon-toolkit/aeon/pull/2831"><img align="absmiddle"  alt="ReviewNB" height="28" class="BotMessageButtonImage" src="https://raw.githubusercontent.com/ReviewNB/support/master/images/button_reviewnb.png"/></a> 

 See visual diffs & provide feedback on Jupyter Notebooks. 

---

 <i>Powered by <a href='https://www.reviewnb.com/?utm_source=gh'>ReviewNB</a></i>
aeon-actions-bot[bot]: 
## Thank you for contributing to `aeon`

I have added the following labels to this PR based on the title: **[ $\\color{#FEF1BE}{\\textsf{enhancement}}$ ]**.
I would have added the following labels to this PR based on the changes made: **[ $\\color{#45FD64}{\\textsf{examples}}$, $\\color{#31FCCD}{\\textsf{forecasting}}$ ]**, however some package labels are already present.

The [Checks](https://github.com/aeon-toolkit/aeon/pull/2831/checks) tab will show the status of our automated tests. You can click on individual test runs in the tab or "Details" in the panel below to see more information if there is a failure.

If our `pre-commit` code quality check fails, any trivial fixes will automatically be pushed to your PR unless it is a draft.

Don't hesitate to ask questions on the `aeon` [Slack](https://join.slack.com/t/aeon-toolkit/shared_invite/zt-22vwvut29-HDpCu~7VBUozyfL_8j3dLA) channel if you have any.

### PR CI actions

These checkboxes will add labels to enable/disable CI functionality for this PR. This may not take effect immediately, and a new commit may be required to run the new configuration.

- [ ] Run `pre-commit` checks for all files
- [ ] Run `mypy` typecheck tests
- [ ] Run all `pytest` tests and configurations
- [ ] Run all notebook example tests
- [ ] Run numba-disabled `codecov` tests
- [ ] Stop automatic `pre-commit` fixes (always disabled for drafts)
- [ ] Disable numba cache loading
- [ ] Push an empty commit to re-run CI checks
    

Patch:
diff --git a/aeon/forecasting/__init__.py b/aeon/forecasting/__init__.py
index de203a0b..7a331f69 100644
--- a/aeon/forecasting/__init__.py
+++ b/aeon/forecasting/__init__.py
@@ -1,13 +1,13 @@
 """Forecasters."""
 
 __all__ = [
-    "DummyForecaster",
+    "NaiveForecaster",
     "BaseForecaster",
     "RegressionForecaster",
     "ETSForecaster",
 ]
 
-from aeon.forecasting._dummy import DummyForecaster
 from aeon.forecasting._ets import ETSForecaster
+from aeon.forecasting._naive import NaiveForecaster
 from aeon.forecasting._regression import RegressionForecaster
 from aeon.forecasting.base import BaseForecaster
diff --git a/aeon/forecasting/_dummy.py b/aeon/forecasting/_naive.py
similarity index 60%
rename from aeon/forecasting/_dummy.py
rename to aeon/forecasting/_naive.py
index 7525b6cc..8b7deede 100644
--- a/aeon/forecasting/_dummy.py
+++ b/aeon/forecasting/_naive.py
@@ -1,24 +1,24 @@
-"""DummyForecaster always predicts the last value seen in training."""
+"""Naive Forecaster."""
 
 from aeon.forecasting.base import BaseForecaster
 
 
-class DummyForecaster(BaseForecaster):
-    """Dummy forecaster always predicts the last value seen in training."""
+class NaiveForecaster(BaseForecaster):
+    """Naive forecaster that always predicts the last value seen in training."""
 
     def __init__(self):
-        """Initialize DummyForecaster."""
+        """Initialize NaiveForecaster."""
         self.last_value_ = None
         super().__init__(horizon=1, axis=1)
 
     def _fit(self, y, exog=None):
-        """Fit dummy forecaster."""
+        """Fit Naive forecaster."""
         y = y.squeeze()
         self.last_value_ = y[-1]
         return self
 
     def _predict(self, y=None, exog=None):
-        """Predict using dummy forecaster."""
+        """Predict using Naive forecaster."""
         return self.last_value_
 
     def _forecast(self, y, exog=None):
diff --git a/aeon/forecasting/base.py b/aeon/forecasting/base.py
index cf2db8d8..23950fa0 100644
--- a/aeon/forecasting/base.py
+++ b/aeon/forecasting/base.py
@@ -4,6 +4,9 @@ A simplified first base class for forecasting models.
 
 """
 
+__maintainer__ = ["TonyBagnall"]
+__all__ = ["BaseForecaster"]
+
 from abc import abstractmethod
 
 import numpy as np
diff --git a/examples/forecasting/forecasting.ipynb b/examples/forecasting/forecasting.ipynb
index 0e0b4ac7..5d98504f 100644
--- a/examples/forecasting/forecasting.ipynb
+++ b/examples/forecasting/forecasting.ipynb
@@ -193,9 +193,9 @@
    "cell_type": "code",
    "source": [
     "# Fit then predict\n",
-    "from aeon.forecasting import DummyForecaster\n",
+    "from aeon.forecasting import NaiveForecaster\n",
     "\n",
-    "d = DummyForecaster()\n",
+    "d = NaiveForecaster()\n",
     "print(d.get_tag(\"y_inner_type\"))\n",
     "d.fit(y)\n",
     "p = d.predict()\n",


Test patch:
diff --git a/aeon/forecasting/tests/test_base.py b/aeon/forecasting/tests/test_base.py
index 22c15901..bd4e26a6 100644
--- a/aeon/forecasting/tests/test_base.py
+++ b/aeon/forecasting/tests/test_base.py
@@ -4,12 +4,12 @@ import numpy as np
 import pandas as pd
 import pytest
 
-from aeon.forecasting import DummyForecaster
+from aeon.forecasting import NaiveForecaster
 
 
 def test_base_forecaster():
     """Test base forecaster functionality."""
-    f = DummyForecaster()
+    f = NaiveForecaster()
     y = np.random.rand(50)
     f.fit(y)
     p1 = f.predict()
@@ -26,7 +26,7 @@ def test_base_forecaster():
 
 def test_convert_y():
     """Test y conversion in forecasting base."""
-    f = DummyForecaster()
+    f = NaiveForecaster()
     y = np.random.rand(50)
     with pytest.raises(ValueError, match="Input axis should be 0 or 1"):
         f._convert_y(y, axis=2)