spectralClustering: Spectral Clustering

View source: R/spectralClustering.r

spectralClusteringR Documentation

Spectral Clustering

Description

Perform the famous spectral clustering algorithms. There are three variants. The default one is the third type.

Usage

spectralClustering(affinity, K, type = 3)

Arguments

affinity

Similarity matrix

K

Number of clusters

type

The variants of spectral clustering to use.

Value

A vector consisting of cluster labels of each sample.

Examples



#load data
data(data1)
data(data2)
data(weight1)
data(weight2)

#standard normalization of the datasets
data1 = standardNormalization(data1)
data2 = standardNormalization(data2)

# Calculate boosted distance matrices(here we calculate Euclidean Distance, 
Dist1 = dist2_w(as.matrix(data1),as.matrix(data1),weight1)
Dist2 = dist2_w(as.matrix(data2),as.matrix(data2),weight2)

# Next, construct similarity graphs
W1 = affinityMatrix(Dist1)
W2 = affinityMatrix(Dist2)

#
W = SNF(list(W1,W2), 20, 20)

# 
labels = spectralClustering(W, 3)

pfruan/abSNF documentation built on Sept. 16, 2022, 5:40 a.m.