fastkmed {kmed} | R Documentation |
Simple and fast k-medoid algorithm
Description
This function runs the simple and fast k-medoid algorithm proposed by Park and Jun (2009).
Usage
fastkmed(distdata, ncluster, iterate = 10, init = NULL)
Arguments
distdata |
A distance matrix (n x n) or dist object. |
ncluster |
A number of clusters. |
iterate |
A number of iterations for the clustering algorithm. |
init |
A vector of initial objects as the cluster medoids (see Details). |
Details
The simple and fast k-medoids, which sets a set of medoids as the cluster centers, adapts the k-means algorithm for medoid up-dating. The new medoids of each iteration are calculated in the within cluster only such that it gains speed.
init = NULL
is required because the Park and Jun (2009) has
a particular method to select the initial medoids. The initial medoids
are selected by
v_j = \sum_{i=1}^n \frac{d_{ij}}{\sum_{l=1}^n d_{il}},
\quad j = 1, 2, 3, \ldots, n
where the first k of the v_j
is selected if the number of
clusters is k.
init
can be provided with a vector of id objects. The length of
the vector has to be equal to the number of clusters. However, assigning
a vector in the init
argument, the algorithm is no longer the simple
and fast k-medoids algorithm. The inckmed
function,
for example, defines a different method to select the initial medoid
though it applies the fastkmed
function.
Value
Function returns a list of components:
cluster
is the clustering memberships result.
medoid
is the id medoids.
minimum_distance
is the distance of all objects to their cluster
medoid.
Author(s)
Weksi Budiaji
Contact: budiaji@untirta.ac.id
References
Park, H., Jun, C., 2009. A simple and fast algorithm for k-medoids clustering. Expert Systems with Applications 36, pp. 3336-3341.
Examples
num <- as.matrix(iris[,1:4])
mrwdist <- distNumeric(num, num, method = "mrw")
result <- fastkmed(mrwdist, ncluster = 3, iterate = 50)
table(result$cluster, iris[,5])