Table of Contents

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

T

The numeric type for calculations (e.g., float, double).

Inheritance
TransformerBase<T, Matrix<T>, Matrix<T>>
PaCMAP<T>
Implements
IDataTransformer<T, Matrix<T>, Matrix<T>>
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

nComponents int

Target dimensionality. Defaults to 2.

nNeighbors int

Number of neighbors for nearby pairs. Defaults to 10.

mnRatio double

Ratio of mid-near pairs to neighbors. Defaults to 0.5.

fpRatio double

Ratio of further pairs to neighbors. Defaults to 2.0.

nIter int

Number of optimization iterations. Defaults to 450.

learningRate double

Learning rate for optimization. Defaults to 1.0.

randomState int?

Random seed for reproducibility.

columnIndices int[]

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

int

NNeighbors

Gets the number of neighbors.

public int NNeighbors { get; }

Property Value

int

SupportsInverseTransform

Gets whether this transformer supports inverse transformation.

public override bool SupportsInverseTransform { get; }

Property Value

bool

Methods

FitCore(Matrix<T>)

Fits PaCMAP and computes the embedding.

protected override void FitCore(Matrix<T> data)

Parameters

data Matrix<T>

GetFeatureNamesOut(string[]?)

Gets the output feature names after transformation.

public override string[] GetFeatureNamesOut(string[]? inputFeatureNames = null)

Parameters

inputFeatureNames string[]

Returns

string[]

InverseTransformCore(Matrix<T>)

Inverse transformation is not supported.

protected override Matrix<T> InverseTransformCore(Matrix<T> data)

Parameters

data Matrix<T>

Returns

Matrix<T>

TransformCore(Matrix<T>)

Returns the embedding computed during Fit.

protected override Matrix<T> TransformCore(Matrix<T> data)

Parameters

data Matrix<T>

Returns

Matrix<T>