Learn R Programming

ClusterR (version 1.3.3)

AP_preferenceRange: Affinity propagation preference range

Description

Affinity propagation preference range

Usage

AP_preferenceRange(data, method = "bound", threads = 1)

Arguments

data

a matrix. Either a similarity matrix (where number of rows equal to number of columns) or a 3-dimensional matrix where the 1st, 2nd and 3rd column correspond to (i-index, j-index, value) triplet of a similarity matrix.

method

a character string specifying the preference range method to use. One of 'exact', 'bound'. See the details section for more information.

threads

an integer specifying the number of cores to run in parallel ( applies only if method is set to 'exact' which is more computationally intensive )

Details

Given a set of similarities, data, this function computes a lower bound, pmin, on the value for the preference where the optimal number of clusters (exemplars) changes from 1 to 2, and the exact value of the preference, pmax, where the optimal number of clusters changes from n-1 to n. For N data points, there may be as many as N^2-N pair-wise similarities (note that the similarity of data point i to k need not be equal to the similarity of data point k to i). These may be passed in an NxN matrix of similarities, data, where data(i,k) is the similarity of point i to point k. In fact, only a smaller number of relevant similarities need to be provided, in which case the others are assumed to be -Inf. M similarity values are known, can be passed in an Mx3 matrix data, where each row of data contains a pair of data point indices and a corresponding similarity value: data(j,3) is the similarity of data point data(j,1) to data point data(j,2).

A single-cluster solution may not exist, in which case pmin is set to NaN. The AP_preferenceRange uses one of the methods below to compute pmin and pmax:

exact : Computes the exact values for pmin and pmax (Warning: This can be quite slow) bound : Computes the exact value for pmax, but estimates pmin using a bound (default)

References

https://www.psi.toronto.edu/affinitypropagation/preferenceRange.m

Examples

Run this code

set.seed(1)
dat = matrix(sample(1:255, 2500, replace = TRUE), 100, 25)

smt = 1.0 - distance_matrix(dat, method = 'euclidean', upper = TRUE, diagonal = TRUE)
diag(smt) = 0.0

ap_range = AP_preferenceRange(smt, method = "bound")

Run the code above in your browser using DataLab