Skip to content

Commit

Permalink
[FIX] Backward compatibility: missing prediction_intervals (#1224)
Browse files Browse the repository at this point in the history
  • Loading branch information
JQGoh authored Dec 16, 2024
1 parent c6959f4 commit 2d0af6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 6 additions & 4 deletions nbs/core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
" config_dict[attr] = getattr(self, attr, None)\n",
" \n",
"\n",
" if save_dataset:\n",
" config_dict.update(\n",
" {\n",
Expand Down Expand Up @@ -1648,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",
Expand Down
9 changes: 5 additions & 4 deletions neuralforecast/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1534,9 +1534,11 @@ 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
config_dict[attr] = getattr(self, attr, None)

if save_dataset:
config_dict.update(
{
Expand Down Expand Up @@ -1641,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:
Expand Down

0 comments on commit 2d0af6c

Please sign in to comment.