GainRatio<T>

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

Gain Ratio for feature selection.

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

Implements: IFixedCountFeatureSelector<T>, ISupervisedFeatureSelector<T>

For Beginners

Information Gain can be unfairly high for features with many unique values (like IDs). Gain Ratio fixes this by dividing by how spread out the feature itself is. A feature with 100 values needs more “justification” to score high than one with just 2 values.

How It Works

Gain Ratio normalizes Information Gain by the intrinsic value (entropy) of the feature itself. This prevents bias toward features with many values and provides a more balanced measure of feature relevance.

Constructors

Constructor Summary
GainRatio(int nFeaturesToSelect, int nBins, int[] columnIndices)

Properties

Property Summary
Vector<T> GainRatios { get; }
Vector<T> InformationGains { get; }
Vector<T> IntrinsicValues { get; }
bool SupportsInverseTransform { get; }
int NBins { get; }
int NFeaturesToSelect { 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)