-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add util function to help automatically get horizon #1509
base: main
Are you sure you want to change the base?
Conversation
qlib/contrib/data/dataset.py
Outdated
# Try to guess horizon | ||
if isinstance(handler, dict): | ||
handler = init_instance_by_config(handler) | ||
elif isinstance(handler, str): # pickled handler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we write it like this?
if isinstance(handler, (dict, str))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
# Unlikely the label doesn't use future information | ||
if max_horizon < 2: | ||
return 0 | ||
return max_horizon + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it return max_horizon+1
here instead of return max_horizon
or return max_horizon-min_horizon
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is consistent with exisiting deinition of "horizon" in other code like DDG-DA and TRA. There is no official documentation, TRA workflow config use max_horizon to truncate and DDG-DA use max_horizon + 1. I use max_horizon + 1 here just to make things safe.
Any suggestion from qlib team?
Add util function to help automatically get horizon
Description
Add util function to help automatically get horizon
Motivation and Context
In some code like TRA and DDG-DA, horizon is manually passed into the model. Which is not convenient to automate the workflow. Add a util function to help guess the horizon by label.
How Has This Been Tested?
pytest qlib/tests/test_all_pipeline.py
under upper directory ofqlib
.Screenshots of Test Results (if appropriate):
Pipeline test:
Your own tests:
qrun workflow_config_tra_Alpha158.yaml and remove the "horizon" field in the yaml config
Types of changes