Performs PaCMAP dimensionality reduction on the input data. This function provides a user-friendly interface with input validation before calling the Rust implementation.
Usage
pacmap(
data,
knn = NULL,
n_dim = 2L,
knn_method = c("ivf", "nndescent", "kmknn", "balltree", "hnsw", "annoy", "exhaustive"),
nn_params = params_nn(),
pacmap_params = params_pacmap(),
seed = 42L,
.verbose = TRUE
)Arguments
- data
Numerical matrix or data frame. The data to embed of shape samples x features. Will be coerced to a matrix.
- knn
Optional
NearestNeighboursclass. If provided, PaCMAP will skip the k-nearest neighbour graph generation and use this one. Needs at leastn_nearneighbours, and the near pairs are ranked from what it holds, so build itn_near + 50wide to match the internal search. Defaults toNULL.- n_dim
Integer. Number of dimensions in the embedding space. Defaults to
2L.- knn_method
Character. (Approximate) Nearest neighbour method to use. One of
"kmknn","hnsw","annoy","nndescent","balltree","ivf"or"exhaustive". Defaults to"ivf".- nn_params
Named list. Nearest neighbour search parameters, see
params_nn().- pacmap_params
Named list. PaCMAP algorithm parameters, see
params_pacmap(). Controls near/mid-near/further pair counts. The kNN search runsn_near + 50wide and the near pairs are the best of those by locally scaled distance.- seed
Integer. Random seed for reproducibility. Defaults to
42L.- .verbose
Logical or integer. Controls verbosity.
TRUEor1Lprints timed stages and epochs every 50,2Ladds parameters and the kNN internals,FALSEor0Lis silent. Defaults toTRUE.
Examples
d <- manifold_synthetic_data(type = "clusters", n_samples = 500L)
emb <- pacmap(d$data, .verbose = FALSE)
dim(emb)
#> [1] 500 2
