ML: Clustering Algorithm R Package-K Center Point clustering

Source: Internet
Author: User

K-medodis and K-means are similar, but K-medoids and K-means are different, the difference lies in the selection of the center point, in K-means, we will take the center point as the average of all data points in the current cluster, in In the K-medoids algorithm, we will select such a point from the current cluster-its minimum distance from all other points in the current cluster-as the center point. The K-medodis algorithm is not susceptible to dirty data due to errors and the like, but the computational amount is obviously larger than the K-means, which is generally only suitable for small data volumes . K-medoids mainly applies to the PAM function in the cluster packet in the R language.

K Center Point Clustering

    • Cluster::p AM
    • FPC::p AMK

cluster::p am

Usage: Pam (x, K, diss = Inherits (x, "dist"), metric = "Euclidean", Medoids = NULL, stand = FALSE, cluster.only = FALSE, Do.swap = TRUE, Keep.diss =!diss &&!cluster.only && n <, Keep.data =!diss &&A MP;!cluster.only, pamonce = FALSE, Trace.lev = 0)

    • X: Cluster Object
    • K: is the number of clusters ( positive integer specifying the numbers of the clusters, less than the NUM of observations)

Sample code

> Newiris <-iris[,-5]> Library (Cluster)> KC <-pam (x=newiris,k=3)#  kc$clustering#Kc[1:length (KC)]> > table (iris$species, kc$clustering)                           1  2  3  setosa       0  0  versicolor  48  2  virginica   14 36

Summary:

An improved algorithm for the disadvantage of K-means is susceptible to extreme value. The difference in principle is that the sample mean point is not taken when the center point of a class is selected, and the sample that is selected to the remaining sample distance within the category is centered.

FPC::p AMK

Compared to the PAM function, the number of reference clusters can be given, referring to Kmenas and Kmeansrun

USAGE:PAMK (data,krange=2:10,criterion= "ASW", Usepam=true, Scaling=false, alpha=0.001, diss=inherits (data, "dist"), Critout=false, ns=10, Seed=null, ...)

Sample code

Newiris <-<-<-pamk (newiris,krang=1:5) plot (Pam (Newiris, KC2$NC))

legend

The FPC package also provides another function plotcluster () that shows the clustering analysis, and it is worth mentioning that the data will be projected into different clusters

Plotcluster (Newiris,kc2$cluster)

Pending verification:

Why are there only two clusters?

References:

    • http://blog.csdn.net/helen1313/article/details/38111125

ML: Clustering Algorithm R Package-K Center Point clustering

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.