How can SelectFromModel enforce both a minimum importance and a maximum feature count?
Classic MLLevel: IntermediateImportance threshold and cap
How can SelectFromModel enforce both a minimum importance and a maximum feature count?
Hints
- Two constraints apply together.
- A maximum is not a requested exact count.
Answer
Set threshold together with max_features. A feature-count cap does not force inclusion of low-importance features below the threshold; inspect the actual retained mask.
Source and licence: scikit-learn 1.7.2 — feature selection · BSD-3-Clause · answer: Quantoros editorial