There are two types of partitional algorithms which are as follows −
K-means clustering − K-means clustering is the most common partitioning algorithm. K-means reassigns each data in the dataset to only one of the new clusters formed. A record or data point is assigned to the nearest cluster using a measure of distance or similarity. There are the following steps used in the K-means clustering:
It can select K initial cluster centroid c1, c2, c3 ... . ck.
It can assign each instance x in the S cluster whose centroid is nearest to x.
For each cluster, recompute its centroid based on which elements are contained in that cluster.
Go to (b) until convergence is completed.
It can separate the object (data points) into K clusters.
It is used to cluster center (centroid) = the average of all the data points in the cluster.
It can assign each point to the cluster whose centroid is nearest (using distance function).
The initial values for the means are arbitrarily assigned. These can be assigned randomly or perhaps can use the values from the first k input items themselves. The convergence element can be based on the squared error, but they are required not to be. For example, the algorithm is assigned to different clusters. Other termination techniques have simply locked at a fixed number of iterations. A maximum number of iterations can be included to ensure shopping even without convergence.
Algorithm
Input
D = {t1t2 ... tn} // Set of elements k // Number of desired clusters
Output
K // Set of clusters
K-means algorithm −
assign initial values for means m1m2... mk
repeat
assign each item ti to the cluster which has the closest mean
calculate the new mean for each cluster
until convergence criteria are met
Nearest neighbour algorithm − An algorithm that is similar to the single link technique is called the nearest neighbour algorithm. With this serial algorithm, items are iteratively combined into the current clusters that are closest. In this algorithm, a threshold t can determine if items will be inserted into existing clusters or if a new cluster is generated.
Algorithm
Input
D = {t1t2 ... tn} // Set of elements A // Adjacency matrix showing distance between elements
Output
K // Set of clusters Nearest neighbour algorithm K1 = {t1}; K = {K1}; k = 1; for i = 2 to n do find the tm in some cluster Km in K such that dis {ti, tm} is the smallest; If dis {ti, tm} $\leqslant$ t then Km = Km $\cup$ ti else k = k + 1; Kk = {ti}