Learn R Programming

clue (version 0.2-9)

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)

Arguments

Value

  • An object of class "cl_membership" with the matrix of 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 cba, cclust, cluster, e1071, flexclust, flexmix, kernlab, 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