fix(processor): use fields_group in TanhProcess to protect labels - #2313
Open
Syed Muhammad Ali Hassan (ali2002-collab) wants to merge 1 commit into
Open
Conversation
Fixes microsoft#1687. Replace brittle LABEL substring masking with the same fields_group selection used by other processors so feature columns are denoised and labels stay unchanged by default.
Author
|
@microsoft-github-policy-service agree |
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.
Description
TanhProcesspreviously selected columns withget_level_values(1).str.contains("LABEL"), which is inconsistent with Qlib's handler MultiIndex layout (feature/labelon level 0, column names likeLABEL0on level 1) and with other processors.This change makes
TanhProcesstakefields_group(default"feature") and transform only that group viaget_group_columns, applyingtanh(x - 1)to features while leaving labels untouched.fields_group=Nonestill transforms all columns.Motivation and Context
Fixes #1687.
The old LABEL substring mask is brittle. Simply switching to level 0 would also be wrong for standard handlers, because level 0 uses lowercase
"label", not"LABEL". Usingfields_groupmatches the pattern used byFillna,CSZScoreNorm, and related processors.How Has This Been Tested?
pytest qlib/tests/test_all_pipeline.pyunder upper directory ofqlib.Ran:
pytest tests/data_mid_layer_tests/test_processor.py::TestTanhProcess -vAlso checked Black (
-l 120), flake8, and pylint on the touched processor module.Screenshots of Test Results (if appropriate):
Pipeline test:
N/A (processor unit tests; no market data required)
Your own tests:
Types of changes