What does VarianceThreshold do and when is it useful?
easyAnswer
- Drops features with variance below a threshold — most commonly zero-variance (constants) that carry no information.
- Useful as a cheap pre-filter to remove degenerate features before training or before applying more expensive selection methods.
- In high-dimensional sparse data (bag-of-words with rare terms), a low-variance filter (e.g., threshold = 0.01) can slash the feature count dramatically with almost no signal loss.
- Doesn't consider the target — pair with a supervised method for real feature selection.
Check yourself — multiple choice
- Rank features by correlation with y
- Drop features with variance below a threshold — cheap pre-filter for degenerate features
- Only used for classification
- It replaces cross-validation
VarianceThreshold: kill zero/near-zero variance columns as a cheap pre-filter.
#feature-selection
Practise Supervised Learning
215 interview questions in this topic.
Related questions
- Why does L1 (Lasso) produce sparse coefficients but L2 (Ridge) does not?
- When would you use Group Lasso instead of standard Lasso?
- How is feature importance computed from a decision tree or random forest?
- What is Weight of Evidence (WoE) encoding?
- Filter, wrapper, and embedded feature selection — how do they differ?
- How does Recursive Feature Elimination (RFE) work?