sklears-feature-selection 0.1.1

Feature selection algorithms for sklears - scikit-learn compatible ML in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
//! Auto-generated module
//!
//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)

use scirs2_core::ndarray::{Array1, Array2};
use std::collections::HashMap;
use std::time::Duration;

use super::types_2::{
    AcquisitionFunction, ImportanceGetter, ImputerConfig, PipelineConfiguration,
    PowerTransformerConfig, QuantileTransformerConfig, ScoringMetric, TrainedStep,
};

#[derive(Debug, Clone)]
/// FeatureOrigin
pub enum FeatureOrigin {
    /// Original
    Original(usize),
    /// Engineered
    Engineered {
        /// source_features
        source_features: Vec<usize>,
        /// operation
        operation: String,
    },
    /// Transformed
    Transformed {
        /// source_feature
        source_feature: usize,
        /// transformation
        transformation: String,
    },
}
#[derive(Debug, Clone)]
/// OutlierParams
pub struct OutlierParams {
    /// decision_function
    pub decision_function: Array1<f64>,
    /// threshold
    pub threshold: f64,
}
/// Information about a trained pipeline
#[derive(Debug, Clone)]
pub struct PipelineInfo {
    /// n_preprocessing_steps
    pub n_preprocessing_steps: usize,
    /// n_feature_engineering_steps
    pub n_feature_engineering_steps: usize,
    /// n_selection_methods
    pub n_selection_methods: usize,
    /// has_dimensionality_reduction
    pub has_dimensionality_reduction: bool,
    /// has_model_selection
    pub has_model_selection: bool,
    /// config
    pub config: PipelineConfiguration,
}
#[derive(Debug, Clone)]
/// LoggingLevel
pub enum LoggingLevel {
    /// None
    None,
    /// Error
    Error,
    /// Warning
    Warning,
    /// Info
    Info,
    /// Debug
    Debug,
    /// Trace
    Trace,
}
/// Feature mapping for tracking feature transformations
#[derive(Debug, Clone)]
pub struct FeatureMapping {
    /// original_features
    pub original_features: usize,
    /// final_features
    pub final_features: usize,
    /// feature_names
    pub feature_names: Vec<String>,
    /// feature_origins
    pub feature_origins: Vec<FeatureOrigin>,
    /// transformation_history
    pub transformation_history: Vec<TransformationStep>,
}
#[derive(Debug, Clone)]
/// CorrelationMethod
pub enum CorrelationMethod {
    /// Pearson
    Pearson,
    /// Spearman
    Spearman,
    /// Kendall
    Kendall,
}
#[derive(Debug, Clone)]
/// TransformationStep
pub struct TransformationStep {
    /// step_name
    pub step_name: String,
    /// input_features
    pub input_features: usize,
    /// output_features
    pub output_features: usize,
    /// transformation_type
    pub transformation_type: TransformationType,
}
#[derive(Debug, Clone)]
/// PowerParams
pub struct PowerParams {
    /// lambdas
    pub lambdas: Array1<f64>,
}
#[derive(Debug, Clone)]
/// PrefetchStrategy
pub enum PrefetchStrategy {
    /// None
    None,
    /// Sequential
    Sequential,
    /// Random
    Random,
    /// Adaptive
    Adaptive,
}
#[derive(Debug, Clone)]
/// OutlierMethod
pub enum OutlierMethod {
    /// IsolationForest
    IsolationForest,
    /// LocalOutlierFactor
    LocalOutlierFactor,
    /// OneClassSVM
    OneClassSVM,
    /// EllipticEnvelope
    EllipticEnvelope,
}
#[derive(Debug, Clone)]
/// TransformationType
pub enum TransformationType {
    /// OneToOne
    OneToOne,
    /// OneToMany
    OneToMany,
    /// ManyToOne
    ManyToOne,
    /// ManyToMany
    ManyToMany,
}
#[derive(Debug, Clone)]
/// WindowStatistic
pub enum WindowStatistic {
    /// Mean
    Mean,
    /// Std
    Std,
    /// Min
    Min,
    /// Max
    Max,
    /// Median
    Median,
    /// Skewness
    Skewness,
    /// Kurtosis
    Kurtosis,
}
/// Type-safe selection count specification
#[derive(Debug, Clone)]
pub enum SelectionCount {
    /// K
    K(usize),
    /// Percentile
    Percentile(f64),
    /// FDR
    FDR(f64),
    /// FPR
    FPR(f64),
    /// FWER
    FWER(f64),
}
#[derive(Debug, Clone)]
/// OutlierConfig
pub struct OutlierConfig {
    /// method
    pub method: OutlierMethod,
    /// threshold
    pub threshold: f64,
    /// contamination
    pub contamination: f64,
}
#[derive(Debug, Clone)]
/// PowerMethod
pub enum PowerMethod {
    /// YeoJohnson
    YeoJohnson,
    /// BoxCox
    BoxCox,
}
#[derive(Debug, Clone)]
/// ScalerParams
pub struct ScalerParams {
    /// mean
    pub mean: Array1<f64>,
    /// scale
    pub scale: Array1<f64>,
}
/// Optimization configuration for performance tuning
#[derive(Debug, Clone)]
pub struct OptimizationConfiguration {
    /// use_simd
    pub use_simd: bool,
    /// chunk_size
    pub chunk_size: usize,
    /// thread_pool_size
    pub thread_pool_size: Option<usize>,
    /// memory_pool_size
    pub memory_pool_size: usize,
    /// cache_size
    pub cache_size: usize,
    /// prefetch_strategy
    pub prefetch_strategy: PrefetchStrategy,
    /// vectorization_threshold
    pub vectorization_threshold: usize,
}
#[derive(Debug, Clone)]
/// RobustScalerParams
pub struct RobustScalerParams {
    /// center
    pub center: Array1<f64>,
    /// scale
    pub scale: Array1<f64>,
}
#[derive(Debug, Clone)]
/// ErrorHandling
pub enum ErrorHandling {
    /// Strict
    Strict,
    /// Graceful
    Graceful,
    /// Logging
    Logging,
}
#[derive(Debug, Clone)]
/// MissingValueIndicator
pub enum MissingValueIndicator {
    /// NaN
    NaN,
    /// Value
    Value(f64),
}
/// Individual preprocessing step in the pipeline
#[derive(Debug, Clone)]
pub enum PreprocessingStep {
    /// StandardScaler
    StandardScaler {
        /// config
        config: StandardScalerConfig,
        /// trained_params
        trained_params: Option<ScalerParams>,
    },
    /// RobustScaler
    RobustScaler {
        /// config
        config: RobustScalerConfig,
        /// trained_params
        trained_params: Option<RobustScalerParams>,
    },
    /// MinMaxScaler
    MinMaxScaler {
        /// config
        config: MinMaxScalerConfig,
        /// trained_params
        trained_params: Option<MinMaxScalerParams>,
    },
    /// QuantileTransformer
    QuantileTransformer {
        /// config
        config: QuantileTransformerConfig,
        /// trained_params
        trained_params: Option<QuantileParams>,
    },
    /// PowerTransformer
    PowerTransformer {
        /// config
        config: PowerTransformerConfig,
        /// trained_params
        trained_params: Option<PowerParams>,
    },
    /// MissingValueImputer
    MissingValueImputer {
        /// config
        config: ImputerConfig,
        /// trained_params
        trained_params: Option<ImputerParams>,
    },
    /// OutlierRemover
    OutlierRemover {
        /// config
        config: OutlierConfig,
        /// trained_params
        trained_params: Option<OutlierParams>,
    },
}
#[derive(Debug, Clone)]
/// RobustScalerConfig
pub struct RobustScalerConfig {
    /// with_centering
    pub with_centering: bool,
    /// with_scaling
    pub with_scaling: bool,
    /// quantile_range
    pub quantile_range: (f64, f64),
}
#[derive(Debug, Clone)]
/// MinMaxScalerConfig
pub struct MinMaxScalerConfig {
    /// feature_range
    pub feature_range: (f64, f64),
    /// clip
    pub clip: bool,
}
#[derive(Debug, Clone)]
/// StandardScalerConfig
pub struct StandardScalerConfig {
    /// with_mean
    pub with_mean: bool,
    /// with_std
    pub with_std: bool,
}
#[derive(Debug, Clone)]
/// MinMaxScalerParams
pub struct MinMaxScalerParams {
    /// min
    pub min: Array1<f64>,
    /// scale
    pub scale: Array1<f64>,
}
#[derive(Debug, Clone)]
/// UnivariateMethod
pub enum UnivariateMethod {
    /// Chi2
    Chi2,
    /// ANOVA
    ANOVA,
    /// MutualInfo
    MutualInfo,
    /// Correlation
    Correlation,
}
#[derive(Debug, Clone)]
/// RFEEstimator
pub enum RFEEstimator {
    /// SVM
    SVM,
    /// RandomForest
    RandomForest,
    /// LinearRegression
    LinearRegression,
    /// LogisticRegression
    LogisticRegression,
}
/// Pipeline metadata for tracking execution and performance
#[derive(Debug, Clone)]
pub struct PipelineMetadata {
    /// total_training_time
    pub total_training_time: Duration,
    /// total_transform_time
    pub total_transform_time: Duration,
    /// memory_usage_peak
    pub memory_usage_peak: usize,
    /// feature_reduction_ratio
    pub feature_reduction_ratio: f64,
    /// performance_metrics
    pub performance_metrics: HashMap<String, f64>,
    /// validation_results
    pub validation_results: Option<ValidationResults>,
}
#[derive(Debug, Clone)]
/// TreeEstimatorType
pub enum TreeEstimatorType {
    /// RandomForest
    RandomForest,
    /// ExtraTrees
    ExtraTrees,
    /// GradientBoosting
    GradientBoosting,
    /// AdaBoost
    AdaBoost,
}
#[derive(Debug, Clone)]
/// ValidationStrategy
pub enum ValidationStrategy {
    /// None
    None,
    /// Basic
    Basic,
    /// Comprehensive
    Comprehensive,
    /// Statistical
    Statistical,
}
/// Supporting enums and structs for configuration
#[derive(Debug, Clone)]
pub enum MemoryOptimization {
    /// None
    None,
    /// Conservative
    Conservative,
    /// Aggressive
    Aggressive,
}
#[derive(Debug, Clone)]
/// QuantileParams
pub struct QuantileParams {
    /// quantiles
    pub quantiles: Array2<f64>,
    /// references
    pub references: Array1<f64>,
}
#[derive(Debug, Clone)]
/// Distribution
pub enum Distribution {
    /// Uniform
    Uniform,
    /// Normal
    Normal,
}
/// Model selection step for choosing optimal features for specific models
#[derive(Debug, Clone)]
pub enum ModelSelectionStep {
    /// CrossValidationSelection
    CrossValidationSelection {
        /// estimator
        estimator: ModelEstimator,
        /// cv_folds
        cv_folds: usize,
        /// scoring
        scoring: ScoringMetric,
        /// feature_scores
        feature_scores: Option<Array1<f64>>,
    },
    /// ForwardSelection
    ForwardSelection {
        /// estimator
        estimator: ModelEstimator,
        /// max_features
        max_features: usize,
        /// scoring
        scoring: ScoringMetric,
        /// selected_features
        selected_features: Option<Vec<usize>>,
    },
    /// BackwardElimination
    BackwardElimination {
        /// estimator
        estimator: ModelEstimator,
        /// min_features
        min_features: usize,
        /// scoring
        scoring: ScoringMetric,
        /// remaining_features
        remaining_features: Option<Vec<usize>>,
    },
    /// StepwiseSelection
    StepwiseSelection {
        /// estimator
        estimator: ModelEstimator,
        /// direction
        direction: StepwiseDirection,
        /// p_enter
        p_enter: f64,
        /// p_remove
        p_remove: f64,
        /// selected_features
        selected_features: Option<Vec<usize>>,
    },
    /// BayesianOptimization
    BayesianOptimization {
        /// estimator
        estimator: ModelEstimator,
        /// acquisition_function
        acquisition_function: AcquisitionFunction,
        /// n_calls
        n_calls: usize,
        /// optimal_features
        optimal_features: Option<Vec<usize>>,
    },
}
#[derive(Debug, Clone)]
/// ICAAlgorithm
pub enum ICAAlgorithm {
    /// Parallel
    Parallel,
    /// Deflation
    Deflation,
}
#[derive(Debug, Clone)]
/// ImputerParams
pub struct ImputerParams {
    /// statistics
    pub statistics: Array1<f64>,
}
#[derive(Debug, Clone)]
/// BinningStrategy
pub enum BinningStrategy {
    /// Uniform
    Uniform,
    /// Quantile
    Quantile,
    /// KMeans
    KMeans,
}
/// Type-safe selection threshold specification
#[derive(Debug, Clone)]
pub enum SelectionThreshold {
    /// Mean
    Mean,
    /// Median
    Median,
    /// Absolute
    Absolute(f64),
    /// Percentile
    Percentile(f64),
    /// Auto
    Auto,
}
#[derive(Debug, Clone)]
/// ValidationResults
pub struct ValidationResults {
    /// cross_validation_scores
    pub cross_validation_scores: Vec<f64>,
    /// stability_scores
    pub stability_scores: Vec<f64>,
    /// robustness_scores
    pub robustness_scores: Vec<f64>,
    /// statistical_significance
    pub statistical_significance: bool,
}
/// Selection method configuration with type safety
#[derive(Debug, Clone)]
pub enum SelectionMethod {
    /// UnivariateFilter
    UnivariateFilter {
        /// method
        method: UnivariateMethod,
        /// k
        k: SelectionCount,
        /// score_func
        score_func: UnivariateScoreFunction,
    },
    /// RecursiveFeatureElimination
    RecursiveFeatureElimination {
        /// estimator
        estimator: RFEEstimator,
        /// n_features
        n_features: SelectionCount,
        /// step
        step: f64,
        /// importance_getter
        importance_getter: ImportanceGetter,
    },
    /// SelectFromModel
    SelectFromModel {
        /// estimator
        estimator: ModelEstimator,
        /// threshold
        threshold: SelectionThreshold,
        /// prefit
        prefit: bool,
        /// max_features
        max_features: Option<usize>,
    },
    /// VarianceThreshold
    VarianceThreshold {
        /// threshold
        threshold: f64,
        /// feature_variance
        feature_variance: Option<Array1<f64>>,
    },
    /// CorrelationFilter
    CorrelationFilter {
        /// threshold
        threshold: f64,
        /// method
        method: CorrelationMethod,
        /// correlation_matrix
        correlation_matrix: Option<Array2<f64>>,
    },
    /// MutualInformation
    MutualInformation {
        /// k
        k: SelectionCount,
        /// discrete_features
        discrete_features: Vec<bool>,
        /// random_state
        random_state: Option<u64>,
    },
    /// LASSO
    LASSO {
        /// alpha
        alpha: f64,
        /// max_iter
        max_iter: usize,
        /// tol
        tol: f64,
        /// coefficients
        coefficients: Option<Array1<f64>>,
    },
    /// ElasticNet
    ElasticNet {
        /// alpha
        alpha: f64,
        /// l1_ratio
        l1_ratio: f64,
        /// max_iter
        max_iter: usize,
        /// tol
        tol: f64,
        /// coefficients
        coefficients: Option<Array1<f64>>,
    },
    /// TreeBased
    TreeBased {
        /// estimator_type
        estimator_type: TreeEstimatorType,
        /// n_estimators
        n_estimators: usize,
        /// max_depth
        max_depth: Option<usize>,
        /// feature_importances
        feature_importances: Option<Array1<f64>>,
    },
    /// GeneticAlgorithm
    GeneticAlgorithm {
        /// population_size
        population_size: usize,
        /// n_generations
        n_generations: usize,
        /// mutation_rate
        mutation_rate: f64,
        /// crossover_rate
        crossover_rate: f64,
        /// best_individuals
        best_individuals: Option<Vec<Vec<bool>>>,
    },
    /// ParticleSwarmOptimization
    ParticleSwarmOptimization {
        /// n_particles
        n_particles: usize,
        /// n_iterations
        n_iterations: usize,
        /// inertia
        inertia: f64,
        /// cognitive
        cognitive: f64,
        /// social
        social: f64,
        /// best_positions
        best_positions: Option<Vec<Vec<f64>>>,
    },
    /// SimulatedAnnealing
    SimulatedAnnealing {
        /// initial_temp
        initial_temp: f64,
        /// cooling_rate
        cooling_rate: f64,
        /// min_temp
        min_temp: f64,
        /// max_iter
        max_iter: usize,
        /// current_solution
        current_solution: Option<Vec<bool>>,
    },
}
#[derive(Debug, Clone)]
/// UnivariateScoreFunction
pub enum UnivariateScoreFunction {
    /// Chi2
    Chi2,
    /// FClassif
    FClassif,
    /// FRegression
    FRegression,
    /// MutualInfoClassif
    MutualInfoClassif,
    /// MutualInfoRegression
    MutualInfoRegression,
}
#[derive(Debug, Clone)]
/// SVDSolver
pub enum SVDSolver {
    /// Auto
    Auto,
    /// Full
    Full,
    /// Arpack
    Arpack,
    /// Randomized
    Randomized,
}
#[derive(Debug, Clone)]
/// SVDAlgorithm
pub enum SVDAlgorithm {
    /// Randomized
    Randomized,
    /// Arpack
    Arpack,
}
#[derive(Debug, Clone)]
/// StepwiseDirection
pub enum StepwiseDirection {
    /// Forward
    Forward,
    /// Backward
    Backward,
    /// Both
    Both,
}
#[derive(Debug, Clone)]
/// ImputationStrategy
pub enum ImputationStrategy {
    /// Mean
    Mean,
    /// Median
    Median,
    /// Mode
    Mode,
    /// Constant
    Constant,
    /// KNN
    KNN,
    /// Iterative
    Iterative,
}
#[derive(Debug, Clone)]
/// ModelEstimator
pub enum ModelEstimator {
    /// LinearRegression
    LinearRegression,
    /// LogisticRegression
    LogisticRegression,
    /// RandomForest
    RandomForest,
    /// SVM
    SVM,
    /// XGBoost
    XGBoost,
    /// LightGBM
    LightGBM,
}
#[derive(Debug)]
/// Trained
pub struct Trained {
    _trained_steps: Vec<TrainedStep>,
    _feature_mapping: FeatureMapping,
    _pipeline_metadata: PipelineMetadata,
}