## Getting the memberships of a single soft partition.
d <- dist(USArrests)
hclust_methods <- c("ward", "single", "complete", "average",
"mcquitty", "median", "centroid")
hclust_results <- lapply(hclust_methods, function(m) hclust(d, m))
## Now create an ensemble from the results.
hens <- cl_ensemble(list = hclust_results)
names(hens) <- hclust_methods
## Create a dissimilarity object from this.
d1 <- cl_dissimilarity(hens)
## And compute a soft partition.
require("cluster")
party <- fanny(d1, 2)
cl_membership(party)
## The "nearest" hard partition to this:
as.cl_hard_partition(party)
## (which has the same class ids as cl_class_ids(party)).
## Converting all elements in an ensemble of partitions to their
## memberships.
pens <- cl_boot(USArrests, 30, 3)
pens
pens <- cl_ensemble(list = lapply(pens, cl_membership))
pens
pens[[length(pens)]]
Run the code above in your browser using DataLab