clusterTree | R Documentation |
Given a point cloud, or a matrix of distances, the function clusterTree
computes a density estimator and returns the corresponding cluster tree of superlevel sets (lambda tree and kappa tree; see references).
clusterTree(
X, k, h = NULL, density = "knn", dist = "euclidean", d = NULL,
Nlambda = 100, printProgress = FALSE)
X |
If |
k |
an integer value specifying the parameter of the underlying k-nearest neighbor similarity graph, used to determine connected components. If |
h |
real value: if |
density |
string: if |
dist |
string: can be |
d |
integer: if |
Nlambda |
integer: size of the grid of values of the density estimator, used to compute the cluster tree. High |
printProgress |
logical: if |
The function clusterTree
is an implementation of Algorithm 1 in the first reference.
The function clusterTree
returns an object of class clusterTree
, a list with the following components
density |
Vector of length |
DataPoints |
A list whose elements are the points of |
n |
The number of points stored in the input matrix |
id |
Vector: the IDs associated to the branches of the cluster tree |
children |
A list whose elements are the IDs of the children of each branch, in the same order of |
parent |
Vector: the IDs of the parents of each branch, in the same order of |
silo |
A list whose elements are the horizontal coordinates of the silo of each branch, in the same order of |
Xbase |
Vector: the horiontal coordinates of the branches of the cluster tree, in the same order of |
lambdaBottom |
Vector: the vertical bottom coordinates of the branches of the lambda tree, in the same order of |
lambdaTop |
Vector: the vertical top coordinates of the branches of the lambda tree, in the same order of |
rBottom |
(only if |
rTop |
(only if |
alphaBottom |
Vector: the vertical bottom coordinates of the branches of the alpha tree, in the same order of |
alphaTop |
Vector: the vertical top coordinates of the branches of the alpha tree, in the same order of |
Kbottom |
Vector: the vertical bottom coordinates of the branches of the kappa tree, in the same order of |
Ktop |
Vector: the vertical top coordinates of the branches of the kappa tree, in the same order of |
Fabrizio Lecci
Kent BP, Rinaldo A, Verstynen T (2013). "DeBaCl: A Python Package for Interactive DEnsity-BAsed CLustering." arXiv:1307.8136
Lecci F, Rinaldo A, Wasserman L (2014). "Metric Embeddings for Cluster Trees"
plot.clusterTree
## Generate data: 3 clusters
n <- 1200 #sample size
Neach <- floor(n / 4)
X1 <- cbind(rnorm(Neach, 1, .8), rnorm(Neach, 5, 0.8))
X2 <- cbind(rnorm(Neach, 3.5, .8), rnorm(Neach, 5, 0.8))
X3 <- cbind(rnorm(Neach, 6, 1), rnorm(Neach, 1, 1))
X <- rbind(X1, X2, X3)
k <- 100 #parameter of knn
## Density clustering using knn and kde
Tree <- clusterTree(X, k, density = "knn")
TreeKDE <- clusterTree(X, k, h = 0.3, density = "kde")
par(mfrow = c(2, 3))
plot(X, pch = 19, cex = 0.6)
# plot lambda trees
plot(Tree, type = "lambda", main = "lambda Tree (knn)")
plot(TreeKDE, type = "lambda", main = "lambda Tree (kde)")
# plot clusters
plot(X, pch = 19, cex = 0.6, main = "cluster labels")
for (i in Tree[["id"]]){
points(matrix(X[Tree[["DataPoints"]][[i]],],ncol = 2), col = i, pch = 19,
cex = 0.6)
}
#plot kappa trees
plot(Tree, type = "kappa", main = "kappa Tree (knn)")
plot(TreeKDE, type = "kappa", main = "kappa Tree (kde)")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.