Description Usage Arguments Value Examples
Performs spectral clustering using K-nearest neighbors (where K is passed in as a parameter) using Euclidean distances. Uses K-means clustering on the eigenvectors.
1 | SPECC(data.dt, numClust, numEigen, numNeighbors)
|
data.dt |
Data table of observations |
numClust |
Desired number of clusters |
numEigen |
Desired number of eigenvalues used |
numNeighbors |
Number of neighbors to choose in K-nearest neighbor computation |
Vector of cluster assignments.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | library(data.table)
set.seed(1)
halfcircle <- function(r, center = c(0, 0), class, sign, N=150, noise=0.5) {
angle <- runif(N, 0, pi)
rad <- rnorm(N, r, noise)
data.table(
V1 = rad * cos(angle) + center[1],
V2 = sign * rad * sin(angle) + center[2]
)
}
X.dt <- rbind(
halfcircle(4, c(0, 0), 1, 1),
halfcircle(4, c(4, 2), 2, -1))
result <- SPECC(X.dt, 2, 5, 5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.