Learn R Programming

clue (version 0.1-0)

membership: Memberships of Partitions

Description

Compute the memberships values for objects representing partitions.

Usage

cl_membership(x, k = n_of_classes(x))
as.cl_membership(x)

as.cl_hard_partition(x)

Arguments

x
an R object representing a partition of objects.
k
an integer giving the number of columns (corresponding to class ids) to be used in the membership matrix. Must not be less, and default to, the number of classes in the partition.

Value

  • An object of class "cl_membership" with the matrix of membership values. For as.cl_hard_partition, an object of class "cl_membership" with the membership values of the hard partition obtained by taking the class ids of the (first) maximal membership values.

Details

cl_membership is a generic function.

The methods provided in package clue handle the partitions obtained from clustering functions in the base R distribution, as well as packages cclust, cluster, e1071, and mclust (and of course, clue itself).

as.cl_membership can be used for coercing raw class ids (given as atomic vectors) or membership values (given as numeric matrices) to membership objects.

See Also

is.cl_partition

Examples

Run this code
## 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