filter_variance — Population-variance feature filter

Group: Signal transforms · C ABI: n4m_feature_selection_variance_*

Description

Model-agnostic feature filter by variance.

Parameters

Name

Type

Default

threshold

float

0.0

top_k

int | None

None

API and bindings

C ABI (ABI 2): n4m_feature_selection_variance_create · n4m_feature_selection_variance_destroy · n4m_feature_selection_variance_fit · n4m_feature_selection_variance_is_fitted · n4m_feature_selection_variance_output_cols · n4m_feature_selection_variance_transform. Use the linked public header for the exact signature, configuration, and result handles.

Python (verified public re-export):

from n4m.feature_selection.filter import VarianceFilter

Source signature: VarianceFilter(threshold: float = 0.0, top_k: int | None = None).

R: no current source-verified entry point was found for this catalog method.

MATLAB / Octave: no current source-verified entry point was found for this catalog method.

Explanations

Bibliographic source

Variance thresholding is a basic descriptive-statistics filter with no single canonical method paper. The shipped scoring and tie behavior are defined by the ABI implementation.

Mathematical principle

At fit time, score channel \(j\) by the population variance \(v_j=n^{-1}\sum_i(X_{ij}-\bar X_j)^2\). With no top_k, retain channels satisfying \(v_j>\text{threshold}\) (strict inequality). With top_k, retain the k largest scores; stable ascending ranking makes original channel order the tie-break before the retained indices are emitted.

Appropriate uses

Removing constant or nearly constant wavelengths before modeling.

Limits and validation

Variance depends on units and preprocessing and says nothing about association with y. The selector does not expose a Boolean support mask through the Python API, only transformed columns.

Implementation

Python role API n4m.feature_selection.filter.VarianceFilter; ABI 2 family n4m_feature_selection_variance_{create,fit,transform,output_cols,destroy}.

The ABI-2 implementation is the n4m_feature_selection_variance_* lifecycle in libn4m.

Sources and provenance

https://github.com/GBeurier/nirs4all-methods/blob/main/cpp/src/c_api/c_api_advanced.cpp#L1138


See also: methods index · interactive dashboard