Class PaCMAP<T>
- Namespace
- AiDotNet.Preprocessing.DimensionalityReduction
- Assembly
- AiDotNet.dll
PaCMAP: Pairwise Controlled Manifold Approximation.
public class PaCMAP<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
-
PaCMAP<T>
- Implements
- Inherited Members
Remarks
PaCMAP is a dimensionality reduction method designed to preserve both local and global structure. It uses three types of point pairs with carefully controlled weights during optimization to achieve better structure preservation than t-SNE or UMAP.
The algorithm: 1. Create three types of pairs: nearby (local), mid-near (intermediate), further (global) 2. Initialize embedding using PCA 3. Optimize using attractive/repulsive forces with dynamic weighting 4. Gradually shift from global to local focus during optimization
For Beginners: PaCMAP improves on UMAP/t-SNE by: - Preserving global structure better through mid-near and further pairs - Using controlled pair selection instead of random sampling - Dynamically adjusting focus from global to local structure - Being more robust to hyperparameter choices
Use cases:
- When you need faithful global structure
- When t-SNE/UMAP produces fragmented clusters
- When relative distances between clusters matter
- Biological data, image embeddings, document visualization
Constructors
PaCMAP(int, int, double, double, int, double, int?, int[]?)
Creates a new instance of PaCMAP<T>.
public PaCMAP(int nComponents = 2, int nNeighbors = 10, double mnRatio = 0.5, double fpRatio = 2, int nIter = 450, double learningRate = 1, int? randomState = null, int[]? columnIndices = null)
Parameters
nComponentsintTarget dimensionality. Defaults to 2.
nNeighborsintNumber of neighbors for nearby pairs. Defaults to 10.
mnRatiodoubleRatio of mid-near pairs to neighbors. Defaults to 0.5.
fpRatiodoubleRatio of further pairs to neighbors. Defaults to 2.0.
nIterintNumber of optimization iterations. Defaults to 450.
learningRatedoubleLearning rate for optimization. Defaults to 1.0.
randomStateint?Random seed for reproducibility.
columnIndicesint[]The column indices to use, or null for all columns.
Properties
Embedding
Gets the embedding result.
public double[,]? Embedding { get; }
Property Value
- double[,]
NComponents
Gets the number of components (dimensions).
public int NComponents { get; }
Property Value
NNeighbors
Gets the number of neighbors.
public int NNeighbors { get; }
Property Value
SupportsInverseTransform
Gets whether this transformer supports inverse transformation.
public override bool SupportsInverseTransform { get; }
Property Value
Methods
FitCore(Matrix<T>)
Fits PaCMAP and computes the embedding.
protected override void FitCore(Matrix<T> data)
Parameters
dataMatrix<T>
GetFeatureNamesOut(string[]?)
Gets the output feature names after transformation.
public override string[] GetFeatureNamesOut(string[]? inputFeatureNames = null)
Parameters
inputFeatureNamesstring[]
Returns
- string[]
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>)
Returns the embedding computed during Fit.
protected override Matrix<T> TransformCore(Matrix<T> data)
Parameters
dataMatrix<T>
Returns
- Matrix<T>