RandomProjection<T>
Models & Types · AiDotNet.Preprocessing.DimensionalityReduction
Random Projection for dimensionality reduction.
Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> → RandomProjection<T>
For Beginners
Random projection is surprisingly effective:
- It’s very fast (just matrix multiplication)
- It preserves distances approximately (guaranteed by math!)
- Great for preprocessing before other algorithms
- Works well for very high-dimensional data
Use cases:
- Speeding up distance-based algorithms (kNN, clustering)
- Reducing memory for large datasets
- Preprocessing before other dimensionality reduction
How It Works
Random projection reduces dimensionality by projecting data onto a random subspace. Despite its simplicity, it has strong theoretical guarantees via the Johnson-Lindenstrauss lemma: pairwise distances are approximately preserved with high probability.
Two projection types are supported:
- Gaussian: Random matrix with entries from N(0, 1/k)
- Sparse: Random matrix with mostly zeros (faster, memory efficient)
Constructors
| Constructor | Summary |
|---|---|
RandomProjection(int? nComponents, double? eps, RandomProjectionType projectionType, double density, int? randomState, int[] columnIndices) |
Creates a new instance of RandomProjection. |
Properties
| Property | Summary |
|---|---|
Matrix<T> ProjectionMatrix { get; } |
Gets the projection matrix. |
RandomProjectionType ProjectionType { get; } |
Gets the projection type. |
bool SupportsInverseTransform { get; } |
Gets whether this transformer supports inverse transformation. |
int NComponents { get; } |
Gets the number of components. |
Methods
| Method | Summary |
|---|---|
string[] GetFeatureNamesOut(string[] inputFeatureNames) |
Gets the output feature names after transformation. |