SelectPercentile<T>

Models & Types · AiDotNet.Preprocessing.FeatureSelection.Filter

Selects features based on a percentile of the highest scores.

Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> → SelectPercentile<T>

Implements: ISupervisedFeatureSelector<T>

For Beginners

Instead of saying “keep the top 10 features,” you say “keep the top 25% of features.” This is useful when you want a consistent reduction ratio that scales with the number of features in your dataset.

How It Works

Similar to SelectKBest but selects a percentage of features rather than a fixed number. Useful when you want a consistent selection ratio across datasets of different sizes.

Constructors

Constructor Summary
SelectPercentile(double percentile, Func<Matrix<T>, Vector<T>, ValueTuple<Vector<T>, Vector<T>>> scoreFunction) Creates a selector with a custom scorer, like scikit-learn’s score_func: it receives the data and the target and returns one score per feature (higher is better) and optionally one p-value per feature.
SelectPercentile(double percentile, SelectKBestScoreFunc scoreFunction, int[] columnIndices) Creates a selector that scores features with a built-in scikit-learn scoring function.

Properties

Property Summary
SelectKBestScoreFunc ScoreFunction { get; } Gets the built-in scoring function, used when no custom scorer was supplied.
Vector<T> PValues { get; } Gets the p-value of every feature after fitting, or null when the scoring function has none.
Vector<T> Scores { get; } Gets the score of every feature after fitting.
bool SupportsInverseTransform { get; }
double Percentile { get; }
int[] SelectedIndices { get; }

Methods

Method Summary
Matrix<T> FitTransform(Matrix<T> data, Vector<T> target)
bool[] GetSupportMask()
string[] GetFeatureNamesOut(string[] inputFeatureNames)
void Fit(Matrix<T> data, Vector<T> target)