# Ensemble Coordinator Quick Reference ## Quick Start ```rust use ml::ensemble::coordinator_extended::{ExtendedEnsembleCoordinator, EnsembleConfig}; use ml::ModelPrediction; // Create ensemble with default config let config = EnsembleConfig::default(); let coordinator = ExtendedEnsembleCoordinator::new(config); // Register all 6 models coordinator.register_model("DQN".to_string(), 0.167).await?; coordinator.register_model("PPO".to_string(), 0.167).await?; coordinator.register_model("TFT".to_string(), 0.167).await?; coordinator.register_model("MAMBA-2".to_string(), 0.167).await?; coordinator.register_model("Liquid".to_string(), 0.167).await?; coordinator.register_model("TLOB".to_string(), 0.165).await?; // Get predictions from all models let predictions = vec![ dqn.predict(&features).await?, ppo.predict(&features).await?, tft.predict(&features).await?, mamba2.predict(&features).await?, liquid.predict(&features).await?, tlob.predict(&features).await?, ]; // Make ensemble decision let decision = coordinator.predict(predictions).await?; // Record outcomes for adaptive weighting coordinator.record_outcome("DQN", return_value).await?; // Get current state let weights = coordinator.get_weights().await; let diversity = coordinator.get_diversity_metrics().await; let attribution = coordinator.get_performance_attribution().await; ``` ## Configuration ```rust EnsembleConfig { adaptive_weighting: true, // Enable adaptive weighting min_correlation_threshold: 0.7, // Diversity threshold diversity_adjustment_factor: 0.2, // Diversity weight bonus performance_window_size: 1000, // Rolling window size min_weight: 0.05, // 5% minimum per model max_weight: 0.40, // 40% maximum per model } ``` ## Key Methods | Method | Purpose | Returns | |--------|---------|---------| | `register_model(id, weight)` | Add model to ensemble | `MLResult<()>` | | `predict(predictions)` | Make ensemble decision | `MLResult` | | `record_outcome(id, return)` | Track performance | `MLResult<()>` | | `get_weights()` | Current model weights | `HashMap` | | `get_diversity_metrics()` | Correlation data | `DiversityMetrics` | | `get_performance_attribution()` | Sharpe/win rates | `PerformanceAttribution` | | `get_weight_history()` | Weight evolution | `Vec` | | `get_correlation_heatmap()` | Pairwise correlations | `Vec<(String, String, f64)>` | ## Testing ```bash # Run 6-model test (1000 predictions) cargo run -p ml --example six_model_ensemble --release # Generate visualizations cd ensemble_viz python3 generate_plots.py ``` ## Expected Performance - **Ensemble Sharpe**: 2.7-3.0 (17-30% improvement over best individual) - **Win Rate**: 60% (vs 58% for DQN) - **Latency**: <5ms per ensemble prediction - **Diversity**: 25-35% disagreement rate ## Supported Models 1. **DQN** - Deep Q-Network (momentum-based RL) 2. **PPO** - Proximal Policy Optimization (policy gradient RL) 3. **TFT** - Temporal Fusion Transformer (attention-based) 4. **MAMBA-2** - State Space Model (SSM architecture) 5. **Liquid** - Liquid Neural Network (adaptive dynamics) 6. **TLOB** - Temporal Limit Order Book (microstructure) ## Files - **Core**: `/home/jgrusewski/Work/foxhunt/ml/src/ensemble/coordinator_extended.rs` - **Example**: `/home/jgrusewski/Work/foxhunt/ml/examples/six_model_ensemble.rs` - **Visualization**: `/home/jgrusewski/Work/foxhunt/ml/examples/ensemble_visualization.rs` - **Documentation**: `/home/jgrusewski/Work/foxhunt/SIX_MODEL_ENSEMBLE_ARCHITECTURE.md`