Table of Contents

Class SelectFwe<T>

Namespace
AiDotNet.Preprocessing.FeatureSelection
Assembly
AiDotNet.dll

Selects features based on a family-wise error rate test.

public class SelectFwe<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>>
SelectFwe<T>
Implements
IDataTransformer<T, Matrix<T>, Matrix<T>>
Inherited Members

Remarks

SelectFwe applies Bonferroni correction to control the probability of making even one false positive among all selected features.

This is the most conservative multiple testing correction, dividing the significance threshold by the number of tests.

For Beginners: FWER is the strictest correction: - Controls the probability of ANY false positive - Uses Bonferroni: alpha/number_of_features - Very conservative: may miss true positives - Best when false positives are costly

Constructors

SelectFwe(double, SelectKBestScoreFunc, int[]?)

Creates a new instance of SelectFwe<T>.

public SelectFwe(double alpha = 0.05, SelectKBestScoreFunc scoringFunction = SelectKBestScoreFunc.FRegression, int[]? columnIndices = null)

Parameters

alpha double

Family-wise error rate threshold. Defaults to 0.05.

scoringFunction SelectKBestScoreFunc

The scoring function to use. Defaults to FRegression.

columnIndices int[]

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

Properties

AdjustedPValues

Gets the Bonferroni-adjusted p-values.

public double[]? AdjustedPValues { get; }

Property Value

double[]

Alpha

Gets the family-wise significance level (alpha).

public double Alpha { get; }

Property Value

double

PValues

Gets the original p-values for each feature.

public double[]? PValues { get; }

Property Value

double[]

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 Bonferroni-corrected p-values.

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 passing FWER threshold.

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

Parameters

data Matrix<T>

Returns

Matrix<T>