| create.iknn.graphs | R Documentation |
For each k \in [k_{\mathrm{min}},\,k_{\mathrm{max}}], builds an
intersection-weighted k-NN graph and applies two pruning schemes:
(1) geometric (path-to-edge ratio) and (2) intersection-size.
Optionally performs PCA before graph construction.
create.iknn.graphs(
X,
kmin,
kmax,
max.path.edge.ratio.deviation.thld = 0.1,
path.edge.ratio.percentile = 0.5,
threshold.percentile = 0,
compute.full = TRUE,
with.isize.pruning = FALSE,
with.edge.pruning.stats = FALSE,
pca.dim = 100,
variance.explained = 0.99,
knn.metric = c("euclidean", "linf.simplex"),
linf.tol = sqrt(.Machine$double.eps),
n.cores = 1L,
parallel.mode = c("auto", "k", "bucket", "hybrid", "bucket.prune"),
hybrid.batch.size = 2L,
verbose = TRUE,
knn.cache.path = NULL,
knn.cache.mode = c("none", "read", "write", "readwrite")
)
X |
A numeric matrix (or object coercible to a numeric matrix) with rows = observations and columns = features. |
kmin |
Integer |
kmax |
Integer |
max.path.edge.ratio.deviation.thld |
Numeric in |
path.edge.ratio.percentile |
Numeric in |
threshold.percentile |
Numeric in |
compute.full |
Logical controlling graph-list outputs.
If |
with.isize.pruning |
Logical. If |
with.edge.pruning.stats |
Logical. If |
pca.dim |
Positive integer or |
variance.explained |
Numeric in |
knn.metric |
Character scalar specifying the geometry used for kNN search.
|
linf.tol |
Positive numeric tolerance used only when
|
n.cores |
Integer or |
parallel.mode |
Character execution mode for graph construction:
|
hybrid.batch.size |
Positive integer batch size used when
|
verbose |
Logical; print progress and timing. |
knn.cache.path |
Optional character scalar path to a binary kNN cache file.
Used only when |
knn.cache.mode |
Character cache mode:
|
Geometric pruning uses the deviation threshold
max.path.edge.ratio.deviation.thld and the filtering percentile
path.edge.ratio.percentile. Intersection-size pruning currently uses
a maximum alternative path length of 2.
Output behavior by flags:
compute.full = FALSE: both geom_pruned_graphs and isize_pruned_graphs
are NULL.
compute.full = TRUE and with.isize.pruning = FALSE:
geom_pruned_graphs is returned and isize_pruned_graphs is NULL.
A list of class "iknn_graphs" with entries:
Matrix of per-k edge counts and reductions.
(If the C++ side supplies column names, they’re preserved.
Otherwise we add names consistent with what the C++ returns.)
If compute.full=TRUE, list of geometrically
pruned graphs (adjacency + weights); otherwise NULL.
If compute.full=TRUE and
with.isize.pruning=TRUE, list of intersection-size pruned graphs;
otherwise NULL.
If with.edge.pruning.stats=TRUE, list (per
k) of edge-level statistics; otherwise NULL.
# Generate sample data
X <- matrix(rnorm(100 * 5), 100, 5)
# Basic usage
res1 <- create.iknn.graphs(
X, kmin = 3, kmax = 10, n.cores = 1,
compute.full = FALSE
)
# With custom pruning parameters
res2 <- create.iknn.graphs(
X, kmin = 3, kmax = 10,
max.path.edge.ratio.deviation.thld = 0.1,
path.edge.ratio.percentile = 0.5,
compute.full = TRUE,
n.cores = 1,
verbose = TRUE
)
# View statistics for each k
print(res2$k_statistics)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.