ChiSquareTest<T>

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

Chi-square test for feature selection in classification with categorical features.

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

Implements: IFixedCountFeatureSelector<T>, ISupervisedFeatureSelector<T>

For Beginners

Chi-square tests whether a feature’s values are distributed differently across classes. If feature values are independent of the class (evenly distributed), they can’t help predict the class. High chi-square scores indicate strong association with the target.

How It Works

Uses the chi-square test of independence to measure the association between features and target classes. Features with high chi-square values show strong dependence on the target and are selected.

Constructors

Constructor Summary
ChiSquareTest(int nFeaturesToSelect, double pValueThreshold, int nBins, int[] columnIndices)

Properties

Property Summary
Vector<T> ChiSquareStats { get; }
Vector<T> PValues { 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)