Table of Contents

Class GenericUnivariateSelect<T>

Namespace
AiDotNet.Preprocessing.FeatureSelection
Assembly
AiDotNet.dll

Generic univariate feature selector with configurable mode.

public class GenericUnivariateSelect<T> : TransformerBase<T, Matrix<T>, Matrix<T>>, IDataTransformer<T, Matrix<T>, Matrix<T>>

Type Parameters

T

The numeric type for calculations (e.g., float, double).

Inheritance
TransformerBase<T, Matrix<T>, Matrix<T>>
GenericUnivariateSelect<T>
Implements
IDataTransformer<T, Matrix<T>, Matrix<T>>
Inherited Members

Remarks

GenericUnivariateSelect provides a unified interface to all univariate feature selection methods. You can choose between k_best, percentile, fpr, fdr, and fwe modes.

This is useful when you want to experiment with different selection strategies without changing your code structure.

For Beginners: This is a "swiss army knife" selector: - k_best: Select exactly k features - percentile: Select top X% of features - fpr: Select based on false positive rate - fdr: Select based on false discovery rate - fwe: Select based on family-wise error rate

Constructors

GenericUnivariateSelect(UnivariateSelectMode, object?, SelectKBestScoreFunc, int[]?)

Creates a new instance of GenericUnivariateSelect<T>.

public GenericUnivariateSelect(UnivariateSelectMode mode = UnivariateSelectMode.Percentile, object? param = null, SelectKBestScoreFunc scoringFunction = SelectKBestScoreFunc.FRegression, int[]? columnIndices = null)

Parameters

mode UnivariateSelectMode

The selection mode to use.

param object

The mode-specific parameter (k for KBest, percentile for Percentile, alpha for FPR/FDR/FWE).

scoringFunction SelectKBestScoreFunc

The scoring function to use. Defaults to FRegression.

columnIndices int[]

The column indices to evaluate, or null for all columns.

Properties

Mode

Gets the selection mode.

public UnivariateSelectMode Mode { get; }

Property Value

UnivariateSelectMode

PValues

Gets the p-values for each feature.

public double[]? PValues { get; }

Property Value

double[]

Param

Gets the mode parameter (k, percentile, or alpha depending on mode).

public object Param { get; }

Property Value

object

Scores

Gets the scores for each feature.

public double[]? Scores { get; }

Property Value

double[]

ScoringFunction

Gets the scoring function used.

public SelectKBestScoreFunc ScoringFunction { get; }

Property Value

SelectKBestScoreFunc

SelectedIndices

Gets the indices of selected features.

public int[]? SelectedIndices { get; }

Property Value

int[]

SupportsInverseTransform

Gets whether this transformer supports inverse transformation.

public override bool SupportsInverseTransform { get; }

Property Value

bool

Methods

Fit(Matrix<T>, Vector<T>)

Fits the selector by computing scores and selecting features.

public void Fit(Matrix<T> data, Vector<T> target)

Parameters

data Matrix<T>

The feature matrix.

target Vector<T>

The target values.

FitCore(Matrix<T>)

Fits the selector (requires target via specialized Fit method).

protected override void FitCore(Matrix<T> data)

Parameters

data Matrix<T>

FitTransform(Matrix<T>, Vector<T>)

Fits and transforms the data.

public Matrix<T> FitTransform(Matrix<T> data, Vector<T> target)

Parameters

data Matrix<T>
target Vector<T>

Returns

Matrix<T>

GetFeatureNamesOut(string[]?)

Gets the output feature names after transformation.

public override string[] GetFeatureNamesOut(string[]? inputFeatureNames = null)

Parameters

inputFeatureNames string[]

Returns

string[]

GetSupportMask()

Gets the support mask indicating which features are selected.

public bool[] GetSupportMask()

Returns

bool[]

InverseTransformCore(Matrix<T>)

Inverse transformation is not supported.

protected override Matrix<T> InverseTransformCore(Matrix<T> data)

Parameters

data Matrix<T>

Returns

Matrix<T>

TransformCore(Matrix<T>)

Transforms the data by selecting features.

protected override Matrix<T> TransformCore(Matrix<T> data)

Parameters

data Matrix<T>

Returns

Matrix<T>