ReliefF<T>

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

ReliefF feature selection algorithm.

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

Implements: IFixedCountFeatureSelector<T>, ISupervisedFeatureSelector<T>

For Beginners

ReliefF scores each feature by asking: “Does this feature help distinguish different classes?”

If instances from the same class have similar values but instances from different classes have different values, the feature gets a high score.

Unlike correlation-based methods, ReliefF can detect feature interactions and works well with non-linear relationships.

How It Works

ReliefF is a feature weighting algorithm that estimates feature quality based on how well features distinguish between instances that are near each other.

For each randomly sampled instance, ReliefF:

  1. Finds k nearest neighbors from the same class (hits)
  2. Finds k nearest neighbors from each different class (misses)
  3. Updates feature weights based on distance differences

Constructors

Constructor Summary
ReliefF(int nFeaturesToSelect, int nNeighbors, int nIterations, int? randomState, int[] columnIndices) Creates a new instance of ReliefF.

Properties

Property Summary
Vector<T> FeatureWeights { get; } Gets the computed feature weights.
bool SupportsInverseTransform { get; } Gets whether this transformer supports inverse transformation.
int NFeaturesToSelect { get; } Gets the number of features to select.
int NNeighbors { get; } Gets the number of nearest neighbors used.
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 ReliefF by computing feature weights.