sklears_ensemble/voting/
config.rs

1//! Configuration types and enums for voting ensemble methods
2
3use scirs2_core::ndarray::Array1;
4use sklears_core::types::Float;
5
6/// Voting strategy for ensemble
7#[derive(Debug, Clone, PartialEq)]
8pub enum VotingStrategy {
9    /// Hard voting (majority vote)
10    Hard,
11    /// Soft voting (average of probabilities)
12    Soft,
13    /// Weighted voting based on estimator weights
14    Weighted,
15    /// Confidence-weighted voting based on prediction confidence
16    ConfidenceWeighted,
17    /// Bayesian model averaging
18    BayesianAveraging,
19    /// Rank-based voting using ordinal rankings
20    RankBased,
21    /// Meta-learning voting with learned combination weights
22    MetaVoting,
23    /// Dynamic weight adjustment based on recent performance
24    DynamicWeightAdjustment,
25    /// Uncertainty-aware voting considering prediction uncertainty
26    UncertaintyAware,
27    /// Consensus-based voting requiring minimum agreement
28    ConsensusBased,
29    /// Entropy-weighted voting favoring low-entropy predictions
30    EntropyWeighted,
31    /// Variance-weighted voting favoring low-variance predictions
32    VarianceWeighted,
33    /// Bootstrap aggregation (Bagging)
34    BootstrapAggregation,
35    /// Temperature-scaled soft voting
36    TemperatureScaled,
37    /// Adaptive ensemble voting
38    AdaptiveEnsemble,
39}
40
41/// Configuration for Voting Classifier
42#[derive(Debug, Clone)]
43pub struct VotingClassifierConfig {
44    pub voting: VotingStrategy,
45    pub weights: Option<Vec<Float>>,
46    pub confidence_weighting: bool,
47    pub confidence_threshold: Float,
48    pub min_confidence_weight: Float,
49    pub enable_uncertainty: bool,
50    pub temperature: Float,
51    pub meta_regularization: Float,
52    pub n_bootstrap_samples: usize,
53    pub uncertainty_method: UncertaintyMethod,
54    pub consensus_threshold: Float,
55    pub entropy_weight_factor: Float,
56    pub variance_weight_factor: Float,
57    pub weight_adjustment_rate: Float,
58}
59
60impl Default for VotingClassifierConfig {
61    fn default() -> Self {
62        Self {
63            voting: VotingStrategy::Hard,
64            weights: None,
65            confidence_weighting: false,
66            confidence_threshold: 0.5,
67            min_confidence_weight: 0.1,
68            enable_uncertainty: false,
69            temperature: 1.0,
70            meta_regularization: 0.0,
71            n_bootstrap_samples: 100,
72            uncertainty_method: UncertaintyMethod::Variance,
73            consensus_threshold: 0.7,
74            entropy_weight_factor: 1.0,
75            variance_weight_factor: 1.0,
76            weight_adjustment_rate: 0.1,
77        }
78    }
79}
80
81/// Uncertainty estimation methods
82#[derive(Debug, Clone, PartialEq)]
83pub enum UncertaintyMethod {
84    /// Use prediction variance as uncertainty measure
85    Variance,
86    /// Use prediction entropy as uncertainty measure
87    Entropy,
88    /// Use ensemble disagreement as uncertainty measure
89    EnsembleDisagreement,
90    /// Use prediction confidence as uncertainty measure
91    Confidence,
92    /// Combined uncertainty using multiple methods
93    Combined,
94    /// Bootstrap-based uncertainty estimation
95    Bootstrap,
96    /// Monte Carlo dropout uncertainty (if applicable)
97    MCDropout,
98    /// Bayesian uncertainty estimation
99    Bayesian,
100    /// Temperature-scaled uncertainty
101    TemperatureScaled,
102    /// Quantile-based uncertainty
103    Quantile,
104}
105
106/// Ensemble size recommendations
107#[derive(Debug, Clone)]
108pub struct EnsembleSizeRecommendations {
109    pub min_size: usize,
110    pub max_size: usize,
111    pub sweet_spot: usize,
112    pub diminishing_returns_threshold: usize,
113}
114
115/// Ensemble size analysis results
116#[derive(Debug, Clone)]
117pub struct EnsembleSizeAnalysis {
118    pub performance_curve: Array1<Float>,
119    pub diversity_curve: Array1<Float>,
120    pub optimal_size: usize,
121    pub performance_plateau_size: usize,
122    pub diversity_saturation_size: usize,
123}