microsoft / qlib

Qlib is an AI-oriented quantitative investment platform that aims to realize the potential, empower research, and create value using AI technologies in quantitative investment, from exploring ideas to implementing productions. Qlib supports diverse machine learning modeling paradigms. including supervised learning, market dynamics modeling, and RL.
https://qlib.readthedocs.io/en/latest/
MIT License
14.54k stars 2.53k forks source link

DDG-DA NaN loss #1771

Closed l0ngc closed 2 months ago

l0ngc commented 3 months ago

🐛 Bug Description

To Reproduce

Steps to reproduce the behavior:

  1. download the repo with git clone https://github.com/microsoft/qlib.git
  2. install qlib with cd qlib and pip install .
  3. cd examples/benchmark_dynamic/DDG-DA/
  4. run DDG-DA with python workflow.py run

Expected Behavior

Expect DDG-DA could work and new rolling training backtest report could be printed.

Screenshot

image

Environment

Note: User could run cd scripts && python collect_info.py all under project directory to get system information and paste them here directly.

Additional Notes

I also reproduced this BUG on Google Colab, I used T4 GPU and high RAM as my virtual machine.

https://colab.research.google.com/drive/1T5zIiE-LZi9TdzHIlwVmfV5ag1PdQUw1?usp=sharing

In my local server, I used two 4090 GPUs, one AMD EPYC 7763 CPU, and 1T ram. Both produce the same error.

ZhongHaoAustin commented 3 months ago

You encountered the same issue as I did. To address it, I implemented the following code in qlib/qlib/contrib/meta/data_selection/dataset.py at line 183:

d_train = d_train.replace([np.inf, -np.inf], np.nan)
d_test = d_test.replace([np.inf, -np.inf], np.nan)

After that, I navigated to the qlib directory and executed the following command to install qlib from the source code:

pip install .

Please note that installing from the source code may have specific requirements based on the Python version. In my case, the Python version is 3.8.

l0ngc commented 2 months ago

You encountered the same issue as I did. To address it, I implemented the following code in qlib/qlib/contrib/meta/data_selection/dataset.py at line 183:

d_train = d_train.replace([np.inf, -np.inf], np.nan)
d_test = d_test.replace([np.inf, -np.inf], np.nan)

After that, I navigated to the qlib directory and executed the following command to install qlib from the source code:

pip install .

Please note that installing from the source code may have specific requirements based on the Python version. In my case, the Python version is 3.8.

Oh man, I love you. Thanks for your response!!!

ssyzymssyzym commented 2 months ago
         可能是代码改变了,183行加不了,不合理,我加代码的地方,供参考
        #新加代码
        d_train = d_train.replace([np.inf, -np.inf], np.nan) 
        d_test = d_test.replace([np.inf, -np.inf], np.nan)  
        #下面是原代码
        d_train = d_train.dropna(axis=0)
        d_test = d_test.dropna(axis=0)