Add linear and zero-fill interpolation strategies to TimeSeriesDataSe…#2227
Open
sujanyd wants to merge 3 commits intosktime:mainfrom
Open
Add linear and zero-fill interpolation strategies to TimeSeriesDataSe…#2227sujanyd wants to merge 3 commits intosktime:mainfrom
sujanyd wants to merge 3 commits intosktime:mainfrom
Conversation
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2227 +/- ##
=======================================
Coverage ? 86.76%
=======================================
Files ? 166
Lines ? 9781
Branches ? 0
=======================================
Hits ? 8486
Misses ? 1295
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
[ENH] Addition of other filling strategies for missing timesteps in TimeSeriesDataSet (GH-1409)
Reference Issues/PRs
Fixes #1409
What does this implement/fix? Explain your changes.
Added support for multiple filling strategies for missing timesteps in TimeSeriesDataSet when allow_missing_timesteps=True.
Previously, only forward fill was supported. This PR adds:
"forward_fill" — repeats the last known value (default, backward compatible)
"linear" — linearly interpolates between boundary values for real-valued variables, falls back to forward fill for categorical variables
"zero" — fills missing values with 0.0
Dict support — per-variable strategy e.g. {"value": "linear", "cat": "forward_fill"}
Changes made:
Modified _timeseries.py — added interpolation_strategy parameter to init and interpolation logic to getitem
Added docstring for the new parameter
Added test file tests/test_data/test_interpolation.py
Added demo script for visual verification of all strategies
What should a reviewer concentrate their feedback on?
The interpolation logic inside getitem — specifically how gaps are detected and filled
Whether the fallback to forward fill for categorical variables when "linear" is specified is the right behavior
Edge case handling — gaps at sequence boundaries, multiple consecutive gaps
Backward compatibility — default behavior should be identical to before this change
Did you add any tests for the change?
Yes. Added tests/test_data/test_interpolation.py which covers:
Forward fill (default behavior preserved)
Linear interpolation across a gap
Zero fill
Mixed per-variable strategy using a dictionary
Any other comments?
A demo script is included to visually compare all three strategies on a sample dataset with a gap
Linear interpolation is only applied to real-valued variables — categorical variables always fall back to forward fill regardless of strategy specified
This is a purely additive change — no existing behavior is modified
PR checklist
The PR title starts with [ENH]
Added/modified tests
Used pre-commit hooks when committing to ensure that code is compliant with hooks. Install hooks with pre-commit install.
To run hooks independent of commit, execute pre-commit run --all-files