diff --git a/nbs/docs/tutorials/20_conformal_prediction.ipynb b/nbs/docs/tutorials/20_conformal_prediction.ipynb index d781c668..105cfc03 100644 --- a/nbs/docs/tutorials/20_conformal_prediction.ipynb +++ b/nbs/docs/tutorials/20_conformal_prediction.ipynb @@ -94,212 +94,7 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Seed set to 1\n", - "Seed set to 1\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "f4e4d84cd6a44714adb9be9ab9c030e5", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "Sanity Checking: | | 0/? [00:00" ] diff --git a/nbs/mint.json b/nbs/mint.json index 5c2d0839..b07f8ae3 100644 --- a/nbs/mint.json +++ b/nbs/mint.json @@ -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" ] }, { diff --git a/nbs/utils.ipynb b/nbs/utils.ipynb index e202c9ad..5b056c14 100644 --- a/nbs/utils.ipynb +++ b/nbs/utils.ipynb @@ -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", @@ -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", diff --git a/neuralforecast/utils.py b/neuralforecast/utils.py index 9d15ce1c..4a272dfc 100644 --- a/neuralforecast/utils.py +++ b/neuralforecast/utils.py @@ -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) @@ -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( diff --git a/settings.ini b/settings.ini index 14a2eeda..3bdb8a5b 100644 --- a/settings.ini +++ b/settings.ini @@ -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