Skip to content

fix(processor): use fields_group in TanhProcess to protect labels - #2313

Open
Syed Muhammad Ali Hassan (ali2002-collab) wants to merge 1 commit into
microsoft:mainfrom
ali2002-collab:fix/processor-tanh-fields-group-1687
Open

fix(processor): use fields_group in TanhProcess to protect labels#2313
Syed Muhammad Ali Hassan (ali2002-collab) wants to merge 1 commit into
microsoft:mainfrom
ali2002-collab:fix/processor-tanh-fields-group-1687

Conversation

@ali2002-collab

Copy link
Copy Markdown

Description

TanhProcess previously selected columns with get_level_values(1).str.contains("LABEL"), which is inconsistent with Qlib's handler MultiIndex layout (feature / label on level 0, column names like LABEL0 on level 1) and with other processors.

This change makes TanhProcess take fields_group (default "feature") and transform only that group via get_group_columns, applying tanh(x - 1) to features while leaving labels untouched. fields_group=None still 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". Using fields_group matches the pattern used by Fillna, CSZScoreNorm, and related processors.

How Has This Been Tested?

  • Pass the test by running: pytest qlib/tests/test_all_pipeline.py under upper directory of qlib.
  • If you are adding a new feature, test on your own test scripts.

Ran:
pytest tests/data_mid_layer_tests/test_processor.py::TestTanhProcess -v

Also checked Black (-l 120), flake8, and pylint on the touched processor module.

Screenshots of Test Results (if appropriate):

  1. Pipeline test:
    N/A (processor unit tests; no market data required)

  2. Your own tests:

Screenshot 2026-08-05 at 00 37 01

Types of changes

  • Fix bugs
  • Add new feature
  • Update documentation

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.
@ali2002-collab

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

class TanhProcess(Processor) error

1 participant