SelectPercentile<T>
Models & Types ยท AiDotNet.Preprocessing.FeatureSelection.Filter.Univariate
Selects features according to a percentile of the highest scores.
Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> โ SelectPercentile<T>
Implements: ISupervisedFeatureSelector<T>
For Beginners
Instead of specifying an exact number of features:
- SelectPercentile(50) keeps the top 50% of features
- The actual number depends on your original feature count
- Useful when you want a proportion, not an absolute count
How It Works
SelectPercentile selects the top percentile of features based on a scoring function. For example, selecting the top 10% of features ranked by F-score.
This is similar to SelectKBest but uses a relative threshold (percentile) instead of an absolute number of features.
Constructors
| Constructor | Summary |
|---|---|
SelectPercentile(double percentile, SelectKBestScoreFunc scoringFunction, int[] columnIndices) |
Creates a new instance of SelectPercentile. |
Properties
| Property | Summary |
|---|---|
SelectKBestScoreFunc ScoringFunction { get; } |
Gets the scoring function used. |
Vector<T> PValues { get; } |
Gets the p-values for each feature, or null when the scoring function has none (mutual information). |
Vector<T> Scores { get; } |
Gets the scores for each feature. |
bool SupportsInverseTransform { get; } |
Gets whether this transformer supports inverse transformation. |
double Percentile { get; } |
Gets the percentile of features to select (0-100). |
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 the selector by computing feature scores. |