CosineSimilaritySelector<T>
Models & Types · AiDotNet.Preprocessing.FeatureSelection.Similarity
Cosine Similarity based Feature Selection.
Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> → CosineSimilaritySelector<T>
Implements: IFixedCountFeatureSelector<T>, ISupervisedFeatureSelector<T>
For Beginners
Cosine similarity measures the angle between two vectors, ignoring their length. Features pointing in similar directions as the target are selected, which is useful when scale doesn’t matter.
How It Works
Selects features based on their cosine similarity with the target, measuring directional alignment rather than magnitude.
Constructors
| Constructor | Summary |
|---|---|
CosineSimilaritySelector(int nFeaturesToSelect, int[] columnIndices) |
Properties
| Property | Summary |
|---|---|
Vector<T> CosineSimilarities { get; } |
|
bool SupportsInverseTransform { get; } |
|
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) |