ChiSquare<T>

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

Chi-Square test for feature selection in classification problems.

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

Implements: IFixedCountFeatureSelector<T>, ISupervisedFeatureSelector<T>

For Beginners

Chi-Square asks: “Is there a relationship between this feature and the target class, or could the observed pattern be due to chance?” High chi-square values indicate a strong association. It works best with categorical or discretized features.

How It Works

The Chi-Square test measures the independence between each feature and the target class. Features that are strongly associated with the target (high chi-square statistic) are considered more relevant for classification.

Constructors

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

Properties

Property Summary
Vector<T> ChiSquareScores { get; }
bool SupportsInverseTransform { 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)