fix(examples): handle NaNs in 14-transfer-learning air dataset#3116
Open
jbbqqf wants to merge 1 commit into
Open
fix(examples): handle NaNs in 14-transfer-learning air dataset#3116jbbqqf wants to merge 1 commit into
jbbqqf wants to merge 1 commit into
Conversation
…co#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 unit8co#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 unit8co#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: unit8co#2752 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Collaborator
jakubchlapek
left a comment
There was a problem hiding this comment.
Hey @jbbqqf, thanks for this PR :)
Looks good, small change requested.
What would be really nice for us for this PR is also finding out why this issue was raising an error in the first place (if it was the data that changed or a new interaction with code). Would you be willing to check that out as part of this pull request? :) Thanks
|
|
||
| **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). |
Collaborator
There was a problem hiding this comment.
For future reference, refer to the PR number and link here :) also if you want take credit (by ...)
Suggested change
| - 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). |
Comment on lines
+251
to
+252
| " # downstream and break model training. See issue #2752.\n", | ||
| " series = fill_missing_values(series, fill=\"auto\")\n", |
Collaborator
There was a problem hiding this comment.
bit too verbose compared to the rest of the notebook
should be fine with just
Suggested change
| " # downstream and break model training. See issue #2752.\n", | |
| " series = fill_missing_values(series, fill=\"auto\")\n", | |
| " # fill missing values\n", | |
| " series = fill_missing_values(series, fill=\"auto\")\n", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2752.
Summary
examples/14-transfer-learning.ipynbfails on the air dataset withValueError: ... NaN ...errors during model training. The rawcarrier_passengers.csvcontains gaps that survivelongest_contiguous_slice()(e.g. zero-rows the slice helper does not flag as missing), so the resulting series carry NaNs into model training. As @rafmacalaba reported in #2752, the cleanest workaround is to callfill_missing_values(...)after the slice; @dennisbader acknowledged the notebook needs refactoring (it's one of the few examples that's not run in CI because it's slow).This PR applies that fix in the smallest possible patch:
fill_missing_valuesfromdarts.utils.missing_valuesin the imports cell.load_air(), callfill_missing_values(series, fill="auto")immediately afterlongest_contiguous_slice(). An inline comment cites the issue so a future reader doesn't have to dig.Other Information
darts/package is touched. Onlyexamples/14-transfer-learning.ipynbandCHANGELOG.md.Unreleased>Fixed.Reproduce BEFORE/AFTER yourself (copy-paste)
If you want to verify functionally (slow — downloads the dataset and runs the local-models cells):
What I ran locally
fill_missing_valuesimport + call are present in the patched notebook.load_air()cell (plus the CHANGELOG).Edge cases tested
fill_missing_values(fill="auto")interpolates the gaps before scaling, so downstream models receive finite valuesfill_missing_valuesis a no-op; no behavioral changelongest_contiguous_slice()try/except continueblock — fix is positioned after that guardRisk / blast radius
darts/is modified.fill_missing_values(..., fill="auto")is a public, documented helper used elsewhere in the codebase, so the new dependency is benign.PR drafted with assistance from Claude Code (Anthropic). The change was reviewed manually against
unit8co/darts@master, the discussion in #2752, and the proposed fix from the original reporter. Reviewer can paste the BEFORE/AFTER block above to verify.