RFE<T>
Models & Types ยท AiDotNet.Preprocessing.FeatureSelection.Wrapper
Recursive Feature Elimination for feature selection.
Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> โ RFE<T>
Implements: IFixedCountFeatureSelector<T>, ISupervisedFeatureSelector<T>
For Beginners
RFE is like an elimination tournament for features:
- Start with all features
- Remove the weakest performer each round
- Keep going until you have the desired number of features
- The surviving features are the most important ones
How It Works
RFE performs feature selection by recursively removing features and building a model on the remaining features. It ranks features by importance and removes the least important ones until the desired number of features is reached.
The algorithm:
- Train a model on all features and compute feature importances
- Remove the least important feature(s)
- Repeat until desired number of features is reached
Constructors
| Constructor | Summary |
|---|---|
RFE(int nFeaturesToSelect, int step, RFEImportanceMethod importanceMethod, int[] columnIndices) |
Creates a new instance of RFE. |
Properties
| Property | Summary |
|---|---|
Vector<T> FeatureImportances { get; } |
Gets the feature importances from the final model. |
bool SupportsInverseTransform { get; } |
Gets whether this transformer supports inverse transformation. |
int NFeaturesToSelect { get; } |
Gets the number of features to select. |
int Step { get; } |
Gets the step size (features removed per iteration). |
int[] Ranking { get; } |
Gets the feature ranking (1 = selected, 2+ = elimination order). |
int[] SelectedIndices { get; } |
Gets the indices of selected features. |
Methods
| Method | Summary |
|---|---|
Matrix<T> FitTransform(Matrix<T> data, Vector<T> target) |
Fits and transforms the data. |
bool[] GetSupportMask() |
Gets the support mask indicating which features are selected. |
string[] GetFeatureNamesOut(string[] inputFeatureNames) |
Gets the output feature names after transformation. |
void Fit(Matrix<T> data, Vector<T> target) |
Fits RFE by recursively eliminating features. |