Do.boolean.membership.matrix | R Documentation |
It computes the pairwise membership matrix for a given clustering. The number of rows is equal to the number of columns (the number of examples).
The element m_{ij}
is set to 1 if the examples i
and j
belong to the same cluster, otherwise to 0.
This function may be used also with clusterings that do not define strictly a partition of the data and using
diferent number of clusters for each clustering.
Do.boolean.membership.matrix(cl, dim.M, examplelabels)
cl |
a clustering (list of vectors defining a clustering) |
dim.M |
dimension of the similarity matrix (number of examples) |
examplelabels |
labels of the examples drawn from the original data |
the pairwise boolean membership square matrix.
Giorgio Valentini valentini@di.unimi.it
library("clusterv")
library("stats")
# Synthetic data set generation (3 clusters with 20 examples for each cluster)
M <- generate.sample3(n=20, m=2)
# k-means clustering with 3 clusters
r<-kmeans(t(M), c=3, iter.max = 1000);
# this function is implemented in the clusterv package:
cl <- Transform.vector.to.list(r$cluster);
# generation of boolean membership square matrix:
B <- Do.boolean.membership.matrix(cl, 60, 1:60)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.