Class SelectFdr<T>
- Namespace
- AiDotNet.Preprocessing.FeatureSelection
- Assembly
- AiDotNet.dll
Selects features based on a false discovery rate test.
public class SelectFdr<T> : TransformerBase<T, Matrix<T>, Matrix<T>>, IDataTransformer<T, Matrix<T>, Matrix<T>>
Type Parameters
TThe numeric type for calculations (e.g., float, double).
- Inheritance
-
SelectFdr<T>
- Implements
- Inherited Members
Remarks
SelectFdr applies the Benjamini-Hochberg procedure to control the expected proportion of false discoveries (incorrectly selected features) among the selected features.
Unlike SelectFpr which controls false positives among ALL features, SelectFdr controls false discoveries among SELECTED features only.
For Beginners: FDR correction is more powerful than FPR: - FPR: "At most 5% of all 1000 features are false positives" - FDR: "At most 5% of the 50 features I selected are false positives" - FDR allows more features to be selected while controlling errors
Constructors
SelectFdr(double, SelectKBestScoreFunc, int[]?)
Creates a new instance of SelectFdr<T>.
public SelectFdr(double alpha = 0.05, SelectKBestScoreFunc scoringFunction = SelectKBestScoreFunc.FRegression, int[]? columnIndices = null)
Parameters
alphadoubleTarget FDR level. Defaults to 0.05.
scoringFunctionSelectKBestScoreFuncThe scoring function to use. Defaults to FRegression.
columnIndicesint[]The column indices to evaluate, or null for all columns.
Properties
AdjustedPValues
Gets the FDR-adjusted p-values.
public double[]? AdjustedPValues { get; }
Property Value
- double[]
Alpha
Gets the significance level (alpha) for FDR control.
public double Alpha { get; }
Property Value
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
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
Methods
Fit(Matrix<T>, Vector<T>)
Fits the selector by computing FDR-adjusted p-values.
public void Fit(Matrix<T> data, Vector<T> target)
Parameters
dataMatrix<T>The feature matrix.
targetVector<T>The target values.
FitCore(Matrix<T>)
Fits the selector (requires target via specialized Fit method).
protected override void FitCore(Matrix<T> data)
Parameters
dataMatrix<T>
FitTransform(Matrix<T>, Vector<T>)
Fits and transforms the data.
public Matrix<T> FitTransform(Matrix<T> data, Vector<T> target)
Parameters
dataMatrix<T>targetVector<T>
Returns
- Matrix<T>
GetFeatureNamesOut(string[]?)
Gets the output feature names after transformation.
public override string[] GetFeatureNamesOut(string[]? inputFeatureNames = null)
Parameters
inputFeatureNamesstring[]
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
dataMatrix<T>
Returns
- Matrix<T>
TransformCore(Matrix<T>)
Transforms the data by selecting features passing FDR threshold.
protected override Matrix<T> TransformCore(Matrix<T> data)
Parameters
dataMatrix<T>
Returns
- Matrix<T>