Learn R Programming

swfscMisc (version 1.1)

affin.prop: Affinity Propagation

Description

Runs the Affinity Propagation clustering algorithm of Frey and Dueck, 2007.

Usage

affin.prop(sim.mat, num.iter = 100, stable.iter = 10, shared.pref = "min", lambda = 0.5)

Arguments

sim.mat
a similarity matrix between individuals to be clustered.
num.iter
maximum number of iterations to attempt.
stable.iter
number of sequential iterations for which consistent clustering is considered acceptable.
shared.pref
type of shared preference to use. Can be one of "min", "median", or a numeric value.
lambda
damping factor.

Value

A matrix with one row per sample in 'sim.mat' and one column for each iteration. Values in columns indicate cluster assignment (arbitrary numbers) for each sample.

References

Frey, B.J., and D. Dueck. 2007. Clustering by passing messages between data points. Science 315:972-976

Examples

Run this code
data(iris)

# Take 75 random iris rows for example
iris <- iris[sample(1:nrow(iris), 75), ]
iris <- droplevels(iris)

iris.sim <- -dist(iris[, -5])

iris.affin <- affin.prop(iris.sim, stable.iter = 5)
table(iris$Species, iris.affin[, ncol(iris.affin)])

Run the code above in your browser using DataLab