R/SpectralClustering.R

Defines functions getSpectralClusters

Documented in getSpectralClusters

#' @title Clustering with the smallest eigenvectors from eigenvector Matrix
#' @name getSpectralClusters
#'
#' @description Clustering with the smallest eigenvectors from eigenvector Matrix
#'
#' @param eigenvectorMatrix Eigenvector matrix based on the affinity matrix
#' @param numberOfClusters maximum number of clusters for prediction
#'
#' @details Modified standard function present in kernlab to perform clustering with
#'          graph spectrum using standard version of K-Means
#'
#' @return K-Means Cluster Object
#'
#' @author Luis Gustavo Uzai
#'
#' @importFrom stats kmeans
#'
getSpectralClusters <- function(eigenvectorMatrix, numberOfClusters = 2) {
    smallestEigenvectors <- eigenvectorMatrix$vectors[,
        (ncol(eigenvectorMatrix$vectors) - numberOfClusters + 1):ncol(eigenvectorMatrix$vectors)]
    clusterObject <- stats::kmeans(smallestEigenvectors, centers = numberOfClusters, nstart = 200)
    return(clusterObject)
}

Try the SpecDetec package in your browser

Any scripts or data that you put into this service are public.

SpecDetec documentation built on May 2, 2019, 1:08 p.m.