[ENH] Add optimized D1 layer categorical encoder for v2#2211
Open
Siddhazntx wants to merge 3 commits intosktime:mainfrom
Open
[ENH] Add optimized D1 layer categorical encoder for v2#2211Siddhazntx wants to merge 3 commits intosktime:mainfrom
Siddhazntx wants to merge 3 commits intosktime:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2211 +/- ##
=======================================
Coverage ? 86.67%
=======================================
Files ? 166
Lines ? 9795
Branches ? 0
=======================================
Hits ? 8490
Misses ? 1305
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.
Reference Issues/PRs
Addresses the
label_encoderstask mentioned in the v2 roadmap tracking issue : #1974What does this implement/fix? Explain your changes.
This PR introduces an optimized
D1CategoricalEncoderto the v2 data pipeline to handle categorical and text variables, preventing PyTorch tensor conversion crashes.Key Changes:
_encoders_v2.pyfeaturing aD1CategoricalEncoderthat strictly follows thescikit-learnAPI (fit,transform,inverse_transform).pd.factorize()instead of native Python dictionaries to ensure the encoding process is efficient and scalable for large datasets.NaNvalues without silently dropping them.transformphase (defaulting to0)._warned_colsset to ensure warnings for unseen variables only trigger once per column, preventing terminal flooding during dataloader loops.__init__ofTimeSeriesinside_timeseries_v2.py. Columns specified in thecatargument are now automatically encoded.What should a reviewer concentrate their feedback on?
_timeseries_v2.py's__init__method to ensure it aligns with the intended v2 data ingestion flow.handle_unknown="assign_new"(mapping to 0). Let me know if the core team prefers a different default behavior for the v2 release!Did you add any tests for the change?
Yes. I added a comprehensive
pytestsuite in a newtest_encoders_v2.pyfile. Tests include:test_encoder_fit_transform: Validates integer conversion and preservation of numeric columns usingpd.api.types.is_integer_dtype.test_encoder_inverse_transform: Ensures perfect reverse translation, including restoring trueNaNvalues.test_unseen_variables_warning: Confirms correct fallback assignment and verifies the custom warning triggers.test_only_categorical_columns_selected: Ensures the auto-detect feature properly ignores numeric columns whencolumns=None.Any other comments?
PR checklist
pre-commit install.To run hooks independent of commit, execute
pre-commit run --all-files