Get the App
SLTechnology News&Howtos  ›  Servers  › 

What is k-means clustering in R language clustering algorithm

Shulou Source: shulou.com Published: 2022-06-01 00:24:58 09月16日 Update

R language clustering algorithm in the k-means clustering is how, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

1. Principle analysis:

The k (preset number of categories) samples are randomly selected as the starting center point, and the rest of the samples are classified into the cluster where the similarity center point is the highest (cluster). Then the mean value of the sample coordinates in the current cluster is established as the new center point, and iterates in a cycle until the category to which all samples belong is no longer changed.

two。 Application in R language

In k-means clustering, we apply the kmeans function in the stats package (R language built-in package).

Kmeans (x Hartigan-Wong, Loyd, For-gy, MacQueen))

3. Discriminant analysis with iris dataset as an example

1) apply the model and view the corresponding parameters of the model

Fit_km=kmeans (iris [,-5], center=3)

Fit_ km [1: length (fit_km)]

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Sample mean language central point application model category help algorithm highest clear similar content function principle parameter coordinate location belonging Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Docker NVidia Shulou Tech Info Microsoft