Skip to main content

Module feature_selection

Module feature_selection 

Source
Expand description

Univariate feature selection: variance-threshold filtering and the ANOVA F-test (f_classif) univariate score.

Both selectors operate on a feature matrix x given as one inner Vec<f64> per sample (row), with x[i][j] the value of feature j for sample i; every row must share the same feature count. They return a per-feature result plus a boolean selection mask so a caller can threshold, rank, or inspect the scores directly. The numerics pin the reference-library conventions the equivalence suite checks:

  • variance threshold drops features whose population variance (ddof = 0) is ≤ threshold, keeping variance > threshold, matching sklearn.feature_selection.VarianceThreshold;
  • the ANOVA F-test computes, per feature, the one-way ANOVA F-statistic across the labelled classes and its upper-tail p-value, reproducing sklearn.feature_selection.f_classif (which is itself a per-feature one-way ANOVA). The selection keeps the top-k features by F-score.

This base block backs the FeatureSelection computational method.

Structs§

Selection
The result of running a univariate selector over a feature matrix: the per-feature scores and the boolean selection mask, aligned to column order.

Enums§

FeatureSelectionError
Errors that prevent a selector from scoring a feature matrix.

Functions§

anova_f_pvalues
Computes the per-feature ANOVA F-test p-values (f_classif), in column order.
anova_f_scores
Computes the per-feature ANOVA F-statistics (f_classif), in column order.
anova_f_select
Scores each feature by the ANOVA F-test across the labelled classes (f_classif), keeping the top-k by F-score.
variance_threshold
Selects features whose population variance exceeds threshold.