From 00687d459e601f2f54d94629a80b27f0287feb7f Mon Sep 17 00:00:00 2001 From: jbbqqf Date: Sun, 10 May 2026 00:32:15 +0200 Subject: [PATCH 1/2] fix(examples): handle NaNs in 14-transfer-learning air dataset (#2752) The transfer-learning notebook fails on the air dataset because the raw carrier_passengers.csv contains gaps that survive longest_contiguous_slice() (e.g. zero-rows that the slice helper does not treat as missing). The resulting NaNs propagate into model training and produce SMAPE = NaN errors, as reported in #2752. Fix: call fill_missing_values(series, fill="auto") inside load_air() right after longest_contiguous_slice(), with an inline comment pointing at the issue so a future reader doesn't have to dig through history. Imports the helper from darts.utils.missing_values. Maintainer @dennisbader acknowledged in #2752 that the notebook needs refactoring (it's one of the only ones that isn't tested in CI because it's slow); this is the smallest possible change that unblocks users running the example end-to-end. CHANGELOG entry under Unreleased > Fixed. Refs: https://github.com/unit8co/darts/issues/2752 Co-Authored-By: Claude Opus 4.7 --- CHANGELOG.md | 2 ++ examples/14-transfer-learning.ipynb | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a47a2faaaa..81a6981b8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ but cannot always guarantee backwards compatibility. Changes that may **break co **Fixed** +- Fixed `examples/14-transfer-learning.ipynb` raising a NaN error on the `air` dataset: the `load_air()` helper now calls `fill_missing_values(..., fill="auto")` after `longest_contiguous_slice()` to handle residual gaps in the raw `carrier_passengers.csv`. Closes [#2752](https://github.com/unit8co/darts/issues/2752). + **Dependencies** ### For developers of the library: diff --git a/examples/14-transfer-learning.ipynb b/examples/14-transfer-learning.ipynb index 579e6a5521..089e9e5bec 100644 --- a/examples/14-transfer-learning.ipynb +++ b/examples/14-transfer-learning.ipynb @@ -130,7 +130,8 @@ " RandomForestModel,\n", " Theta,\n", ")\n", - "from darts.utils.losses import SmapeLoss" + "from darts.utils.losses import SmapeLoss\n", + "from darts.utils.missing_values import fill_missing_values" ] }, { @@ -244,6 +245,11 @@ " series = series.longest_contiguous_slice()\n", " except Exception:\n", " continue\n", + " # Fill any residual missing values inside the chosen slice. The raw\n", + " # carrier_passengers.csv occasionally has gaps that survive the\n", + " # longest_contiguous_slice() call (e.g. zero-rows), which produce NaNs\n", + " # downstream and break model training. See issue #2752.\n", + " series = fill_missing_values(series, fill=\"auto\")\n", " # remove static covariates\n", " series = series.with_static_covariates(None)\n", " # remove short series\n", From 677ebd0c00405b8e4dcec0e1831bed6a15557e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ch=C5=82apek?= Date: Tue, 16 Jun 2026 11:39:26 +0200 Subject: [PATCH 2/2] feat: review changes --- CHANGELOG.md | 2 +- examples/14-transfer-learning.ipynb | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4b50b879c..10969f7695 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ but cannot always guarantee backwards compatibility. Changes that may **break co **Fixed** -- Fixed `examples/14-transfer-learning.ipynb` raising a NaN error on the `air` dataset: the `load_air()` helper now calls `fill_missing_values(..., fill="auto")` after `longest_contiguous_slice()` to handle residual gaps in the raw `carrier_passengers.csv`. Closes [#2752](https://github.com/unit8co/darts/issues/2752). +- Fixed `examples/14-transfer-learning.ipynb` raising a NaN error on the `air` dataset by calling `fill_missing_values(..., fill="auto")` to handle residual gaps in the raw `carrier_passengers.csv`. Closes [#3116](https://github.com/unit8co/darts/pull/3116) by [Jean-Baptiste Braun](https://github.com/jbbqqf). - Fixed `_ScaledDotProductAttention` float16 overflow in `masked_fill` under mixed precision training. [#3087](https://github.com/unit8co/darts/pull/3087) by [Robert Ruidisch](https://github.com/robrui). - Fixed a bug in `TimeSeries.quantile()` where the output dtype did not match the input series dtype for dtypes `float32` or `float16`. Now the dtype is correctly propagated. [#3124](https://github.com/unit8co/darts/pull/3124) by [Dennis Bader](https://github.com/dennisbader) - Optuna integration's `PyTorchLightningPruningCallback` for hyperparameter optimization of torch models is now natively available in Darts via `darts.utils.callbacks`. [#3114](https://github.com/unit8co/darts/pull/3114) by [Jakub Chłapek](https://github.com/jakubchlapek). diff --git a/examples/14-transfer-learning.ipynb b/examples/14-transfer-learning.ipynb index 089e9e5bec..b2a5c4b642 100644 --- a/examples/14-transfer-learning.ipynb +++ b/examples/14-transfer-learning.ipynb @@ -245,10 +245,7 @@ " series = series.longest_contiguous_slice()\n", " except Exception:\n", " continue\n", - " # Fill any residual missing values inside the chosen slice. The raw\n", - " # carrier_passengers.csv occasionally has gaps that survive the\n", - " # longest_contiguous_slice() call (e.g. zero-rows), which produce NaNs\n", - " # downstream and break model training. See issue #2752.\n", + " # fill missing values.\n", " series = fill_missing_values(series, fill=\"auto\")\n", " # remove static covariates\n", " series = series.with_static_covariates(None)\n",