View source: R/spectralClustering.r

spectralClustering | R Documentation |

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

spectralClustering(affinity, K, type = 3)

`affinity` |
Similarity matrix |

`K` |
Number of clusters |

`type` |
The variants of spectral clustering to use. |

A vector consisting of cluster labels of each sample.

#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)

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.