🎯 项目成果: - 准确率: 53.10% (2026年测试集) - 任务类型: 二分类 (预测涨/跌) - 特征: OHLCV + RSI + MACD (9个特征) - 训练数据: 2020-2025年BTC小时数据 (52,351序列) - 测试数据: 2026年1-29日 (484序列) 📊 性能指标: - 精确率: 51.79% - 召回率: 49.36% - F1分数: 0.5054 - 预测分布: 非常平衡 (偏差仅-11个) 🔬 实验历史: - 尝试了5种方案 (回归/分类, 不同数据划分) - 分类任务优于回归任务 (53.10% vs 49.5%) - 全量训练避免了过拟合问题 📦 主要模型文件: - models/checkpoints/dlinear_classification_2026/ - best_model.pt (最佳模型) - preprocessor.pkl (预处理器) - test_2026_results.json (测试结果) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
59 lines
1.3 KiB
Python
59 lines
1.3 KiB
Python
"""Training configuration."""
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Literal
|
|
|
|
|
|
@dataclass
|
|
class TrainingConfig:
|
|
"""Configuration for model training."""
|
|
|
|
# Training parameters
|
|
batch_size: int = 64
|
|
max_epochs: int = 100
|
|
learning_rate: float = 0.001
|
|
weight_decay: float = 1e-5
|
|
|
|
# Early stopping
|
|
early_stopping_patience: int = 10
|
|
early_stopping_min_delta: float = 1e-4
|
|
|
|
# Learning rate scheduler
|
|
lr_scheduler: Literal['plateau', 'cosine', 'none'] = 'plateau'
|
|
lr_patience: int = 5
|
|
lr_factor: float = 0.5
|
|
|
|
# Device
|
|
device: str = 'auto' # 'auto', 'mps', 'cuda', or 'cpu'
|
|
|
|
# Logging
|
|
log_interval: int = 10 # Log every N batches
|
|
|
|
# Checkpointing
|
|
save_best: bool = True
|
|
checkpoint_dir: str = './models/checkpoints'
|
|
|
|
def get_device(self) -> str:
|
|
"""Get the device to use for training.
|
|
|
|
Returns:
|
|
Device string ('mps', 'cuda', or 'cpu')
|
|
"""
|
|
import torch
|
|
|
|
if self.device != 'auto':
|
|
return self.device
|
|
|
|
# Auto-detect best available device
|
|
if torch.backends.mps.is_available():
|
|
return 'mps'
|
|
elif torch.cuda.is_available():
|
|
return 'cuda'
|
|
else:
|
|
return 'cpu'
|
|
|
|
|
|
if __name__ == "__main__":
|
|
config = TrainingConfig()
|
|
print(f"Using device: {config.get_device()}")
|