Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


salso (version 0.2.5)

psm: Compute an Adjacency or Pairwise Similarity Matrix

Description

If only one sample is provided, this function computes an adjacency matrix, i.e., a binary matrix whose (i,j) element is one if and only if elements i and j in the partition have the same cluster label. If multiple samples are provided (as rows of the x matrix), this function computes the n-by-n matrix whose (i,j) element gives the relative frequency (i.e., estimated probability) that items i and j are in the same subset (i.e., cluster). This is the mean of the adjacency matrices of the provided samples.

Usage

psm(x, nCores = 0)

Arguments

x

A B-by-n matrix, where each of the B rows represents a clustering of n items using cluster labels. For clustering b, items i and j are in the same cluster if x[b,i] == x[b,j].

nCores

The number of CPU cores to use. A value of zero indicates to use all cores on the system.

Value

A n-by-n symmetric matrix whose (i,j) element gives the relative frequency that that items i and j are in the same subset (i.e., cluster).

Examples

Run this code
# NOT RUN {
partition <- iris.clusterings[1,]
psm(partition)

dim(iris.clusterings)
# For examples, use 'nCores=1' per CRAN rules, but in practice omit this.
probs <- psm(iris.clusterings, nCores=1)
dim(probs)
probs[1:6, 1:6]

# }

Run the code above in your browser using DataLab