CorrelationSelector<T>

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

Feature selector that removes highly correlated features to reduce redundancy.

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

For Beginners

This selector removes duplicate or redundant information from your data.

Imagine you’re collecting data about houses and include both:

  • Square footage of the house
  • Number of rooms
  • Price

Square footage and number of rooms are often highly correlated (bigger houses tend to have more rooms). This selector would detect this relationship and might keep only one of these features, reducing redundancy while preserving the most important information.

By eliminating redundant features:

  • Your model trains faster
  • You reduce the risk of overfitting
  • The model becomes easier to interpret and explain

The threshold setting controls how strict this filtering is:

  • Higher values (e.g., 0.9) allow more features to be included
  • Lower values (e.g., 0.5) result in more features being removed

How It Works

CorrelationSelector identifies and removes features that are highly correlated with other features. When features are strongly correlated, they provide redundant information, so keeping just one of them can simplify your model without losing predictive power.

Constructors

Constructor Summary
CorrelationSelector(double threshold, int[] columnIndices) Creates a new instance of CorrelationSelector.

Properties

Property Summary
Matrix<T> CorrelationMatrix { get; } Gets the correlation matrix computed during fitting.
bool SupportsInverseTransform { get; } Gets whether this transformer supports inverse transformation.
double Threshold { get; } Gets the correlation threshold above which features are considered highly correlated.
int SelectedCount { get; } Gets the number of selected features after fitting.
int[] SelectedFeatures { get; } Gets the indices of selected features after fitting.

Methods

Method Summary
Dictionary<int, T> GetCorrelationsWithSelected(int featureIndex) Gets the correlations between a specific feature and all selected features.
bool[] GetSupportMask() Gets a boolean mask indicating which features are selected.
string[] GetFeatureNamesOut(string[] inputFeatureNames) Gets the output feature names after transformation.