Repository: sktime/sktime
Pull request: num_epochs  renamed to n_epochs in SimpleRNNClassifier and SimpleRNNRegressor

#### Reference Issues/PRs

 Fixes #5485 

#### What does this implement/fix? Explain your changes.

I have renamed num_epoches to n_epoches in sktime/classification/deep_learning/rnn.py and sktime/regression/deep_learning/rnn.py.



Problem statement:
[ENH] `num_epochs` should be renamed to `n_epochs` in `SimpleRNNClassifier` and `SimpleRNNRegressor`
Currently, we take `n_epochs` in all other estimators within the `deep_learning` subpackage with the exception of `SimpleRNNClassifier`. This inconsistency should be addressed with a deprecation of the usage of `num_epochs` in favor of `n_epochs`.

Hints from issue discussion:
agree.

Not a bug though, I would classify this as an enhancement.

Plus, we should do the same for the regressor.
Is this issue open, Can you assign it to me ?
Done! Welcome to sktime :)

Feel free to ask for help if you feel stuck. Thanks

Commit message: Update rnn.py

Patch to review:
diff --git a/sktime/classification/deep_learning/rnn.py b/sktime/classification/deep_learning/rnn.py
index cbac0badb9d..de7ac1dae09 100644
--- a/sktime/classification/deep_learning/rnn.py
+++ b/sktime/classification/deep_learning/rnn.py
@@ -12,7 +12,7 @@
 from sktime.networks.rnn import RNNNetwork
 from sktime.utils.validation._dependencies import _check_dl_dependencies
 
-
+#todo: 0.26.0 - please remove num_epochs parameter and related logic, because parameter num_epochs usage is deprecated and will be renamed to n_epochs
 class SimpleRNNClassifier(BaseDeepClassifier):
     """Simple recurrent neural network.
 
@@ -51,7 +51,7 @@ class SimpleRNNClassifier(BaseDeepClassifier):
 
     def __init__(
         self,
-        num_epochs=100,
+        num_epochs = None,
         batch_size=1,
         units=6,
         callbacks=None,
@@ -63,10 +63,19 @@ def __init__(
         activation="sigmoid",
         use_bias=True,
         optimizer=None,
+        n_epochs=100,
     ):
         _check_dl_dependencies(severity="error")
         super().__init__()
-        self.num_epochs = num_epochs
+        # Deprecated Parameter Handling
+        if num_epochs is not None:
+            warnings.warn(
+                "In SimpleRNNClassifier, the parameter 'num_epochs' is deprecated and will be removed in version 0.26.0. "
+                "It will be renamed to n_epochs. To avoid this warning, update your code to use 'n_epochs'.",
+                DeprecationWarning, stacklevel=2
+            )
+            self.n_epochs = num_epochs
+        self.num_epochs = num_epochs    
         self.batch_size = batch_size
         self.verbose = verbose
         self.units = units
@@ -80,6 +89,7 @@ def __init__(
         self.optimizer = optimizer
         self.history = None
         self._network = RNNNetwork(random_state=random_state, units=units)
+        self.n_epochs = n_epochs
 
     def build_model(self, input_shape, n_classes, **kwargs):
         """Construct a compiled, un-trained, keras model that is ready for training.
@@ -189,7 +199,7 @@ def _fit(self, X, y):
             X,
             y_onehot,
             batch_size=self.batch_size,
-            epochs=self.num_epochs,
+            epochs=self.n_epochs,
             verbose=self.verbose,
             callbacks=self.callbacks_,
         )
@@ -218,7 +228,7 @@ def get_test_params(cls, parameter_set="default"):
         """
         params1 = {}
         params2 = {
-            "num_epochs": 50,
+            "n_epochs": 50,
             "batch_size": 2,
             "units": 5,
             "use_bias": False,
diff --git a/sktime/regression/deep_learning/rnn.py b/sktime/regression/deep_learning/rnn.py
index c32bd81999a..2e21d02a2ce 100644
--- a/sktime/regression/deep_learning/rnn.py
+++ b/sktime/regression/deep_learning/rnn.py
@@ -12,7 +12,7 @@
 from sktime.regression.deep_learning.base import BaseDeepRegressor
 from sktime.utils.validation._dependencies import _check_dl_dependencies
 
-
+#todo: 0.26.0 - please remove num_epochs parameter and related logic, because parameter num_epochs usage is deprecated and will be renamed to n_epochs
 class SimpleRNNRegressor(BaseDeepRegressor):
     """Simple recurrent neural network.
 
@@ -51,7 +51,7 @@ class SimpleRNNRegressor(BaseDeepRegressor):
 
     def __init__(
         self,
-        num_epochs=100,
+        num_epochs = None,
         batch_size=1,
         units=6,
         callbacks=None,
@@ -63,10 +63,19 @@ def __init__(
         activation="linear",
         use_bias=True,
         optimizer=None,
+        n_epochs=100,
     ):
         _check_dl_dependencies(severity="error")
         super().__init__()
-        self.num_epochs = num_epochs
+        # Deprecated Parameter Handling
+        if num_epochs is not None:
+            warnings.warn(
+                "In SimpleRNNRegressor, the parameter 'num_epochs' is deprecated and will be removed in version 0.26.0. "
+                "It will be renamed to n_epochs. To avoid this warning, update your code to use 'n_epochs'.",
+                DeprecationWarning, stacklevel=2
+            )
+            self.n_epochs = num_epochs
+        self.num_epochs = num_epochs  
         self.batch_size = batch_size
         self.verbose = verbose
         self.units = units
@@ -80,6 +89,7 @@ def __init__(
         self.optimizer = optimizer
         self.history = None
         self._network = RNNNetwork(random_state=random_state, units=units)
+        self.n_epochs = n_epochs
 
     def build_model(self, input_shape, **kwargs):
         """Construct a compiled, un-trained, keras model that is ready for training.
@@ -183,7 +193,7 @@ def _fit(self, X, y):
             X,
             y,
             batch_size=self.batch_size,
-            epochs=self.num_epochs,
+            epochs=self.n_epochs,
             verbose=self.verbose,
             callbacks=self.callbacks_,
         )
@@ -212,7 +222,7 @@ def get_test_params(cls, parameter_set="default"):
         """
         params1 = {}
         params2 = {
-            "num_epochs": 50,
+            "n_epochs": 50,
             "batch_size": 2,
             "units": 5,
             "use_bias": False,


Code review comments:
diff_hunk: @@ -63,10 +63,19 @@ def __init__(
         activation="sigmoid",
         use_bias=True,
         optimizer=None,
+        n_epochs=100,
     ):
         _check_dl_dependencies(severity="error")
         super().__init__()
-        self.num_epochs = num_epochs
+        # Deprecated Parameter Handling
+        if num_epochs is not None:
+            warnings.warn(
path: sktime/classification/deep_learning/rnn.py
text: @user1:
minor thing, we should use `warn` from `sktime.utils.warnings`, as that is affected by estimator level configs.

diff_hunk: @@ -12,7 +12,7 @@
 from sktime.networks.rnn import RNNNetwork
 from sktime.utils.validation._dependencies import _check_dl_dependencies
 
-
+#todo: 0.26.0 - please remove num_epochs parameter and related logic, because parameter num_epochs usage is deprecated and will be renamed to n_epochs
path: sktime/classification/deep_learning/rnn.py
text: @user1:
also, mention that n_epochs should be moved to become the first argument