Remove 520 lines of ndarray-based placeholder code that never performed real gradient descent. Production training uses Candle-based trainers in ml::trainers/. Deleted: SimpleNeuralNetwork, TrainingPipeline, NetworkConfig, ActivationType, TrainingMetrics, NetworkInterface, MockNetwork, and 9 associated tests. Kept: DeviceCapabilities, TrainingConfig, sub-module re-exports. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
86 lines
2.4 KiB
Rust
86 lines
2.4 KiB
Rust
//! Simplified ML Training Implementation for Foxhunt HFT System
|
|
//!
|
|
//! This module provides basic ML training functionality optimized for compilation success.
|
|
//! Focus on working implementation over advanced features.
|
|
//!
|
|
//! ## New Unified Data Pipeline
|
|
//!
|
|
//! The training system now uses UnifiedDataLoader with dual data providers:
|
|
//! - DatabentoHistoricalProvider for market data
|
|
//! - BenzingaHistoricalProvider for news sentiment
|
|
//! - UnifiedFeatureExtractor for consistent feature extraction
|
|
|
|
// Sub-modules for specialized training components
|
|
pub mod orchestrator;
|
|
pub mod unified_data_loader;
|
|
pub mod unified_trainer; // NEW: Unified training trait for all models // NEW: Model-agnostic training orchestrator
|
|
|
|
// NO RE-EXPORTS - Use explicit imports: unified_data_loader::{...}
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// Training configuration
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct TrainingConfig {
|
|
pub learning_rate: f64,
|
|
pub batch_size: usize,
|
|
pub epochs: usize,
|
|
pub validation_split: f64,
|
|
pub early_stopping_patience: Option<usize>,
|
|
pub random_seed: Option<u64>,
|
|
}
|
|
|
|
impl Default for TrainingConfig {
|
|
fn default() -> Self {
|
|
Self {
|
|
learning_rate: 0.001,
|
|
batch_size: 32,
|
|
epochs: 100,
|
|
validation_split: 0.2,
|
|
early_stopping_patience: Some(10),
|
|
random_seed: None,
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Device capabilities for performance scoring
|
|
#[derive(Debug, Clone)]
|
|
pub struct DeviceCapabilities {
|
|
pub performance_score: f64,
|
|
pub memory_gb: f64,
|
|
pub compute_units: u32,
|
|
}
|
|
|
|
impl DeviceCapabilities {
|
|
pub fn cpu_default() -> Self {
|
|
Self {
|
|
performance_score: 1.0,
|
|
memory_gb: 8.0,
|
|
compute_units: num_cpus::get() as u32,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use approx::assert_relative_eq;
|
|
|
|
#[test]
|
|
fn test_training_config_default() {
|
|
let config = TrainingConfig::default();
|
|
assert_eq!(config.learning_rate, 0.001);
|
|
assert_eq!(config.batch_size, 32);
|
|
assert_eq!(config.epochs, 100);
|
|
assert_relative_eq!(config.validation_split, 0.2, epsilon = 1e-10);
|
|
}
|
|
|
|
#[test]
|
|
fn test_device_capabilities_cpu_default() {
|
|
let caps = DeviceCapabilities::cpu_default();
|
|
assert_eq!(caps.performance_score, 1.0);
|
|
assert_eq!(caps.memory_gb, 8.0);
|
|
assert!(caps.compute_units > 0);
|
|
}
|
|
}
|