ClassWeightedFS<T>

Models & Types · AiDotNet.Preprocessing.FeatureSelection.Imbalanced

Class-Weighted Feature Selection for imbalanced datasets.

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

Implements: IFixedCountFeatureSelector<T>, ISupervisedFeatureSelector<T>

For Beginners

In datasets where one class has few examples, normal feature selection might favor features that only work for the common class. This method weights the rare class more heavily, ensuring selected features can identify both common and rare cases.

How It Works

Class-Weighted Feature Selection applies class weights when computing feature scores to give more importance to minority class samples. This helps select features that are discriminative for underrepresented classes.

Constructors

Constructor Summary
ClassWeightedFS(int nFeaturesToSelect, ClassWeightingStrategy weightingStrategy, int[] columnIndices)

Properties

Property Summary
ClassWeightingStrategy WeightingStrategy { get; }
Vector<T> ClassWeights { get; } The weight of each class, in ascending order of the (rounded) class labels, like scikit-learn’s compute_class_weight over np.unique(y).
Vector<T> FeatureScores { 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)