Repository: KIT-IAI/pyWATTS

Issue:
Documentation of RMSE Module is outdated
The documentation of the RMSE module is outdated



Discussion:

Patch:
diff --git a/pywatts/modules/root_mean_squared_error.py b/pywatts/modules/root_mean_squared_error.py
index 0eabc2d..12105d2 100644
--- a/pywatts/modules/root_mean_squared_error.py
+++ b/pywatts/modules/root_mean_squared_error.py
@@ -10,33 +10,31 @@ from pywatts.utils._xarray_time_series_utils import _get_time_indeces
 
 logger = logging.getLogger(__name__)
 
+
 class RmseCalculator(BaseTransformer):
     """
     Module to calculate the Root Mean Squared Error (RMSE)
 
-    Creates the RmseCalculator
-
-    :param target: Variable to be used as the target to be predicted (actual value)
-    :type target: str
-    :param predictions: Variable to be used as the predictions
-    :type predictions: list.
+    :param offset: Offset, which determines the number of ignored values in the beginning for calculating the RMSE.
+    :type offset: int
     """
 
-    def __init__(self, name: str = "RmseCalculator"):
+    def __init__(self, name: str = "RmseCalculator", offset=0):
         super().__init__(name)
+        self.offset = offset
 
     def get_params(self) -> Dict[str, object]:
         """
-        Returns a list of parameters used in the RMSE Calculator
+        Returns a dict of parameters used in the RMSE Calculator.
 
         :return: Parameters set for the RMSE calculator
         :rtype: Dict[str, object]
         """
-        return {}
+        return {"offset": self.offset}
 
     def transform(self, y: xr.DataArray, **kwargs: xr.DataArray) -> xr.DataArray:
         """
-        Calculates the RMSE based on the predefined target and predictions variables
+        Calculates the RMSE based on the predefined target and predictions variables.
 
         :param x: the input dataset
         :type x: Optional[xr.DataArray]
@@ -52,20 +50,24 @@ class RmseCalculator(BaseTransformer):
                          "You should add the predictions by a seperate key word arguments if you add the RMSECalculator "
                          "to the pipeline.")
             raise InputNotAvailable("No predictions are provided as input for the RMSE Calculator. "
-                         "You should add the predictions by a seperate key word arguments if you add the RMSECalculator "
-                         "to the pipeline.")
+                                    "You should add the predictions by a seperate key word arguments if you add the RMSECalculator "
+                                    "to the pipeline.")
 
         for key, y_hat in kwargs.items():
             p = y_hat.values
             predictions.append(key)
-            rmse.append(np.sqrt(np.mean((p - t) ** 2)))
+            rmse.append(np.sqrt(np.mean((p[self.offset:] - t[self.offset:]) ** 2)))
 
         time = y.indexes[_get_time_indeces(y)[0]][-1]
         return xr.DataArray(np.array([rmse]), coords={"time": [time], "predictions": predictions},
                             dims=["time", "predictions"])
 
-    def set_params(self, **kwargs):
+    def set_params(self, offset=None):
         """
-        No parameters can be set.
+        Set parameters of the RMSECalculator.
+
+        :param offset: Offset, which determines the number of ignored values in the beginning for calculating the RMSE.
+        :type offset: int
         """
-        pass
+        if offset:
+            self.offset = offset


Test patch:
diff --git a/tests/unit/modules/test_root_mean_squared_error.py b/tests/unit/modules/test_root_mean_squared_error.py
index a342ef6..1c36d0e 100644
--- a/tests/unit/modules/test_root_mean_squared_error.py
+++ b/tests/unit/modules/test_root_mean_squared_error.py
@@ -19,7 +19,13 @@ class TestRMSECalculator(unittest.TestCase):
 
     def test_get_params(self):
         self.assertEqual(self.rmse_calculator.get_params(),
-                         {})
+                         {"offset" : 0})
+
+
+    def test_set_params(self):
+        self.rmse_calculator.set_params(offset=24)
+        self.assertEqual(self.rmse_calculator.get_params(),
+                     {"offset": 24})
 
     def test_transform(self):
         self.rmse_calculator.set_params()