FisherScore<T>

Models & Types · AiDotNet.Preprocessing.FeatureSelection.Filter.Distance

Fisher Score feature selection for classification.

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

Implements: IFixedCountFeatureSelector<T>, ISupervisedFeatureSelector<T>

For Beginners

Fisher Score answers the question: “How well does this feature separate different classes?”

A high Fisher Score means:

  • Classes have very different average values for this feature (high between-class variance)
  • Within each class, values are similar (low within-class variance)

Example: If predicting “is_spam”, a feature like “number of exclamation marks” might have a high Fisher Score because spam emails have many (!!!!) while normal emails have few.

How It Works

Fisher Score measures the discriminative power of each feature by computing the ratio of between-class variance to within-class variance.

For feature f, the Fisher Score is:

where μ_c is the mean of feature f in class c, μ is the global mean, σ_c² is the variance in class c, and n_c is the class size.

Constructors

Constructor Summary
FisherScore(int nFeaturesToSelect, int[] columnIndices) Creates a new instance of FisherScore.

Properties

Property Summary
Vector<T> Scores { get; } Gets the computed Fisher Scores for each feature.
bool SupportsInverseTransform { get; } Gets whether this transformer supports inverse transformation.
int NFeaturesToSelect { get; } Gets the number of features to select.
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 a boolean 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 Fisher Score by computing discriminative power for each feature.