Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Backward compatibility: missing prediction_intervals #1224

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading