OSFS<T>
Models & Types · AiDotNet.Preprocessing.FeatureSelection.Online
Online Streaming Feature Selection (OSFS) of Wu et al. 2013 (“Online Feature Selection with Streaming Features”, IEEE TPAMI 35(5)).
Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> → OSFS<T>
Implements: IFixedCountFeatureSelector<T>, ISupervisedFeatureSelector<T>
For Beginners
Imagine features arriving one by one like a stream. For each new feature, OSFS asks: “Is this related to the target at all?” If yes, it keeps the feature and then re-checks every kept feature: one that tells nothing more about the target once some of the others are known is dropped.
How It Works
The features arrive one at a time, in column order. Each new feature X goes through the paper’s two steps:
- Online relevance analysis: X is discarded when it is independent of the target C,
Ind(C, X | {}).
- Online redundancy analysis: otherwise X joins the best candidate features BCF, and every Y in BCF
is removed when some subset S of the other BCF features (|S| up to MaxConditioningSetSize) makes
it conditionally independent of the target, Ind(C, Y | S).
The independence tests are Fisher’s z test on the partial correlation at level Alpha, as in the
authors’ LOFS toolbox (osfs_z): W = sqrt(n - |S| - 3) atanh(r), independent when the two-sided
p-value 2 Phi(-|W|) exceeds alpha.
OSFS decides the subset size itself. NFeaturesToSelect caps it: when BCF ends larger, the features
with the strongest correlation with the target are kept.
Constructors
| Constructor | Summary |
|---|---|
OSFS(int nFeaturesToSelect, double alpha, int maxConditioningSetSize, int[] columnIndices) |
Creates an OSFS selector. |
Properties
| Property | Summary |
|---|---|
Vector<T> FeatureScores { get; } |
The absolute Pearson correlation of every feature with the target. |
bool SupportsInverseTransform { get; } |
|
double Alpha { get; } |
The significance level of the conditional-independence tests. |
int MaxConditioningSetSize { get; } |
The largest conditioning set the redundancy analysis tries. |
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) |