fix: 修正回归训练中的未来收益率计算公式
- 修复 Label 公式从过去收益率改为未来收益率
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
"""LightGBM 回归训练示例 - 使用因子字符串表达式
|
"""LightGBM 回归训练示例 - 使用因子字符串表达式
|
||||||
|
|
||||||
使用字符串表达式定义因子,训练 LightGBM 回归模型预测未来5日收益率。
|
使用字符串表达式定义因子,训练 LightGBM 回归模型预测未来5日收益率。
|
||||||
Label: return_5 = (close / ts_delay(close, 5)) - 1
|
Label: return_5 = (ts_delay(close, -5) / close) - 1 # 未来5日收益率
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@@ -19,7 +19,8 @@ from src.training import (
|
|||||||
StockFilterConfig,
|
StockFilterConfig,
|
||||||
StockPoolManager,
|
StockPoolManager,
|
||||||
Trainer,
|
Trainer,
|
||||||
Winsorizer, NullFiller,
|
Winsorizer,
|
||||||
|
NullFiller,
|
||||||
)
|
)
|
||||||
from src.training.config import TrainingConfig
|
from src.training.config import TrainingConfig
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ FACTOR_DEFINITIONS = {
|
|||||||
|
|
||||||
# Label 因子定义(不参与训练,用于计算目标)
|
# Label 因子定义(不参与训练,用于计算目标)
|
||||||
LABEL_FACTOR = {
|
LABEL_FACTOR = {
|
||||||
"return_5": "(close / ts_delay(close, 5)) - 1",
|
"return_5": "(ts_delay(close, -5) / close) - 1", # 未来5日收益率
|
||||||
}
|
}
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user