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
TThe numeric type for calculations (e.g., float, double).
- Inheritance
-
GenericUnivariateSelect<T>
- Implements
- 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
modeUnivariateSelectModeThe selection mode to use.
paramobjectThe mode-specific parameter (k for KBest, percentile for Percentile, alpha for FPR/FDR/FWE).
scoringFunctionSelectKBestScoreFuncThe scoring function to use. Defaults to FRegression.
columnIndicesint[]The column indices to evaluate, or null for all columns.
Properties
Mode
Gets the selection mode.
public UnivariateSelectMode Mode { get; }
Property Value
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
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 scores and selecting features.
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.
protected override Matrix<T> TransformCore(Matrix<T> data)
Parameters
dataMatrix<T>
Returns
- Matrix<T>