From 0ad8caaa1549f512bd8fca56eab21fb9c89a67fc Mon Sep 17 00:00:00 2001 From: t-minus Date: Sun, 15 Dec 2024 01:48:53 +0000 Subject: [PATCH 1/2] Fix backward compatibility: missing prediction_intervals Remove test case with large model file --- nbs/core.ipynb | 7 +++++-- neuralforecast/core.py | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/nbs/core.ipynb b/nbs/core.ipynb index 3bb61dbdc..ec6666da9 100644 --- a/nbs/core.ipynb +++ b/nbs/core.ipynb @@ -1546,9 +1546,12 @@ " \"id_col\": self.id_col,\n", " \"time_col\": self.time_col,\n", " \"target_col\": self.target_col,\n", - " \"prediction_intervals\": self.prediction_intervals,\n", - " \"_cs_df\": self._cs_df, # conformity score\n", " }\n", + " for attr in ['prediction_intervals', '_cs_df']:\n", + " # conformal prediction related attributes was not available < 1.7.6\n", + " if hasattr(self, attr):\n", + " config_dict[attr] = getattr(self, attr, None)\n", + "\n", " if save_dataset:\n", " config_dict.update(\n", " {\n", diff --git a/neuralforecast/core.py b/neuralforecast/core.py index fffe4bde5..77ba09f3e 100644 --- a/neuralforecast/core.py +++ b/neuralforecast/core.py @@ -1534,9 +1534,12 @@ def save( "id_col": self.id_col, "time_col": self.time_col, "target_col": self.target_col, - "prediction_intervals": self.prediction_intervals, - "_cs_df": self._cs_df, # conformity score } + for attr in ["prediction_intervals", "_cs_df"]: + # conformal prediction related attributes was not available < 1.7.6 + if hasattr(self, attr): + config_dict[attr] = getattr(self, attr, None) + if save_dataset: config_dict.update( { From 8d213a606be98d43742cdc7d6292981db6c8b66a Mon Sep 17 00:00:00 2001 From: t-minus Date: Mon, 16 Dec 2024 19:34:54 +0000 Subject: [PATCH 2/2] Review: simplify the assginment --- nbs/core.ipynb | 7 +++---- neuralforecast/core.py | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/nbs/core.ipynb b/nbs/core.ipynb index ec6666da9..51fbc6d41 100644 --- a/nbs/core.ipynb +++ b/nbs/core.ipynb @@ -1549,8 +1549,8 @@ " }\n", " for attr in ['prediction_intervals', '_cs_df']:\n", " # conformal prediction related attributes was not available < 1.7.6\n", - " if hasattr(self, attr):\n", - " config_dict[attr] = getattr(self, attr, None)\n", + " config_dict[attr] = getattr(self, attr, None)\n", + " \n", "\n", " if save_dataset:\n", " config_dict.update(\n", @@ -1651,8 +1651,7 @@ " setattr(neuralforecast, attr, config_dict.get(attr, default))\n", " # only restore attribute if available\n", " for attr in ['prediction_intervals', '_cs_df']:\n", - " if attr in config_dict.keys():\n", - " setattr(neuralforecast, attr, config_dict[attr])\n", + " setattr(neuralforecast, attr, config_dict.get(attr, None))\n", "\n", " # Dataset\n", " if dataset is not None:\n", diff --git a/neuralforecast/core.py b/neuralforecast/core.py index 77ba09f3e..2cd7f53d7 100644 --- a/neuralforecast/core.py +++ b/neuralforecast/core.py @@ -1537,8 +1537,7 @@ def save( } for attr in ["prediction_intervals", "_cs_df"]: # conformal prediction related attributes was not available < 1.7.6 - if hasattr(self, attr): - config_dict[attr] = getattr(self, attr, None) + config_dict[attr] = getattr(self, attr, None) if save_dataset: config_dict.update( @@ -1644,8 +1643,7 @@ def load(path, verbose=False, **kwargs): setattr(neuralforecast, attr, config_dict.get(attr, default)) # only restore attribute if available for attr in ["prediction_intervals", "_cs_df"]: - if attr in config_dict.keys(): - setattr(neuralforecast, attr, config_dict[attr]) + setattr(neuralforecast, attr, config_dict.get(attr, None)) # Dataset if dataset is not None: