R: Memberships of Partitions

cl_membership {clue} | R Documentation

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

`x` | an R object representing a partition of objects (for `cl_membership`) or raw memberships or class ids (for `as.cl_membership`).
`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.

### 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 RWeka, cba, cclust, cluster, e1071, flexclust, flexmix, kernlab, mclust, movMF and skmeans (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.

### Value

An object of class `"cl_membership"` with the matrix of membership values.

### See Also

`is.cl_partition`

### Examples

    ## Getting the memberships of a single soft partition.
    d <- dist(USArrests)
    hclust_methods <-
        c("ward", "single", "complete", "average", "mcquitty")
    hclust_results <- lapply(hclust_methods, function(m) hclust(d, m))
    names(hclust_results) <- hclust_methods
    ## Now create an ensemble from the results.
    hens <- cl_ensemble(list = hclust_results)
    ## And add the results of agnes and diana.
    require("cluster")
    hens <- c(hens, list(agnes = agnes(d), diana = diana(d)))
    ## Create a dissimilarity object from this.
    d1 <- cl_dissimilarity(hens)
    ## And compute a soft partition.
    party <- fanny(d1, 2)
    round(cl_membership(party), 5)
    ## The "nearest" hard partition to this:
    as.cl_hard_partition(party)
    ## (which has the same class ids as cl_class_ids(party)).

    ## Extracting the memberships from the elements of an ensemble of
    ## partitions.
    pens <- cl_boot(USArrests, 30, 3)
    pens
    mems <- lapply(pens, cl_membership)
    ## And turning these raw memberships into an ensemble of partitions.
    pens <- cl_ensemble(list = lapply(mems, as.cl_partition))
    pens
    pens[[length(pens)]]

[Package clue version 0.3-54 Index]