Skip to content

Commit

Permalink
Merge branch 'main' into feature/cv_tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
marcopeix committed Oct 15, 2024
2 parents bdd8baf + 23c71bc commit 166ce16
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 243 deletions.
240 changes: 3 additions & 237 deletions nbs/docs/tutorials/20_conformal_prediction.ipynb

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion nbs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"group":"Probabilistic Forecasting",
"pages":[
"docs/tutorials/uncertainty_quantification.html",
"docs/tutorials/longhorizon_probabilistic.html"
"docs/tutorials/longhorizon_probabilistic.html",
"docs/tutorials/conformal_prediction.html"
]
},
{
Expand Down
6 changes: 4 additions & 2 deletions nbs/utils.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,8 @@
" cuts = [alpha / 200 for alpha in reversed(alphas)]\n",
" cuts.extend(1 - alpha / 200 for alpha in alphas)\n",
" for model in model_names:\n",
" scores = cs_df[model].to_numpy().reshape(cs_n_windows, n_series, horizon)\n",
" scores = cs_df[model].to_numpy().reshape(n_series, cs_n_windows, horizon)\n",
" scores = scores.transpose(1, 0, 2)\n",
" # restrict scores to horizon\n",
" scores = scores[:,:,:horizon]\n",
" mean = fcst_df[model].to_numpy().reshape(1, n_series, -1)\n",
Expand Down Expand Up @@ -670,7 +671,8 @@
" cuts = [lv / 100 for lv in level]\n",
" for model in model_names:\n",
" mean = fcst_df[model].to_numpy().ravel()\n",
" scores = cs_df[model].to_numpy().reshape(cs_n_windows, n_series, horizon)\n",
" scores = cs_df[model].to_numpy().reshape(n_series, cs_n_windows, horizon)\n",
" scores = scores.transpose(1, 0, 2)\n",
" # restrict scores to horizon\n",
" scores = scores[:,:,:horizon]\n",
" quantiles = np.quantile(\n",
Expand Down
6 changes: 4 additions & 2 deletions neuralforecast/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,8 @@ def add_conformal_distribution_intervals(
cuts = [alpha / 200 for alpha in reversed(alphas)]
cuts.extend(1 - alpha / 200 for alpha in alphas)
for model in model_names:
scores = cs_df[model].to_numpy().reshape(cs_n_windows, n_series, horizon)
scores = cs_df[model].to_numpy().reshape(n_series, cs_n_windows, horizon)
scores = scores.transpose(1, 0, 2)
# restrict scores to horizon
scores = scores[:, :, :horizon]
mean = fcst_df[model].to_numpy().reshape(1, n_series, -1)
Expand Down Expand Up @@ -538,7 +539,8 @@ def add_conformal_error_intervals(
cuts = [lv / 100 for lv in level]
for model in model_names:
mean = fcst_df[model].to_numpy().ravel()
scores = cs_df[model].to_numpy().reshape(cs_n_windows, n_series, horizon)
scores = cs_df[model].to_numpy().reshape(n_series, cs_n_windows, horizon)
scores = scores.transpose(1, 0, 2)
# restrict scores to horizon
scores = scores[:, :, :horizon]
quantiles = np.quantile(
Expand Down
2 changes: 1 addition & 1 deletion settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ language = English
custom_sidebar = True
license = apache2
status = 2
requirements = coreforecast>=0.0.6 fsspec numpy>=1.21.6 pandas>=1.3.5 torch>=2.0.0 pytorch-lightning>=2.0.0 ray[tune]>=2.2.0 optuna utilsforecast>=0.0.25
requirements = coreforecast>=0.0.6 fsspec numpy>=1.21.6 pandas>=1.3.5 torch>=2.0.0 pytorch-lightning>=2.0.0 ray[tune]>=2.2.0 optuna utilsforecast>=0.2.3
spark_requirements = fugue pyspark>=3.5
aws_requirements = fsspec[s3]
dev_requirements = black gitpython hyperopt matplotlib mypy nbdev==2.3.25 polars pre-commit pyarrow ruff s3fs transformers
Expand Down

0 comments on commit 166ce16

Please sign in to comment.