VarianceThreshold<T>
Models & Types · AiDotNet.Preprocessing.FeatureSelection.Filter.Univariate
Feature selector that removes features with variance below a threshold.
Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> → VarianceThreshold<T>
For Beginners
If a feature has the same value (or nearly the same value) for all samples, it won’t help your model distinguish between different outcomes. This transformer automatically removes such features:
- Constant features (all same value) have variance = 0
- Near-constant features have very low variance
Example: A “Country” column that is “USA” for 99.9% of rows provides little information.
How It Works
VarianceThreshold removes all features whose variance doesn’t meet a minimum threshold. Features with low variance are often not informative because they don’t vary enough across samples to be useful for prediction.
Constructors
| Constructor | Summary |
|---|---|
VarianceThreshold(double threshold, int[] columnIndices) |
Creates a new instance of VarianceThreshold. |
Properties
| Property | Summary |
|---|---|
Vector<T> Variances { get; } |
Gets the computed variances for each feature. |
bool SupportsInverseTransform { get; } |
Gets whether this transformer supports inverse transformation. |
double Threshold { get; } |
Gets the variance threshold. |
int[] SelectedFeatures { get; } |
Gets the indices of selected features. |
Methods
| Method | Summary |
|---|---|
bool[] GetSupportMask() |
Gets a boolean mask indicating which features are selected. |
string[] GetFeatureNamesOut(string[] inputFeatureNames) |
Gets the output feature names after transformation. |