Posts tagged with: k-means

## How K-means clustering works

K-means is the most primitive and easy to use clustering algorithm (also a Machine Learning algorithm).
There are 4 basic steps of K-means:

1. Choose K different initial data points on instance space (as initial centroids) – centroid is the mean points of the clusters that overview the attributes of the classes-.
2. Assign each object to the nearest centroid.
3. After all the object are assigned, recalculate the centroids by taking the averages of the current classes (clusters)
4. Do 2-3 until centroid are stabilized.

Caveats for K-means:

• Although it can be proved that the procedure will always terminate, the k-means algorithm does not necessarily find the most optimal configuration, corresponding to the global objective function minimum.
• The algorithm is also significantly sensitive to the initial randomly selected cluster centres. The k-means algorithm can be run multiple times to reduce this effect.

Here is the basic animation to show the intuition of K-means.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8584313,"math_prob":0.9756357,"size":977,"snap":"2020-45-2020-50","text_gpt3_token_len":194,"char_repetition_ratio":0.1356629,"word_repetition_ratio":0.0,"special_character_ratio":0.19651996,"punctuation_ratio":0.07692308,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98162156,"pos_list":[0,1,2],"im_url_duplicate_count":[null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-12-05T11:31:43Z\",\"WARC-Record-ID\":\"<urn:uuid:f455f064-efe9-446f-a262-db47e3db30d1>\",\"Content-Length\":\"37524\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:1871ab92-fe99-49eb-933d-ed64e3ab8897>\",\"WARC-Concurrent-To\":\"<urn:uuid:39592f5c-1e72-4b9f-b34b-c543a0a042d8>\",\"WARC-IP-Address\":\"198.211.124.34\",\"WARC-Target-URI\":\"https://erogol.com/tag/k-means/\",\"WARC-Payload-Digest\":\"sha1:DYCI62E2YGQ4J4C7NZCMKYKWDWPAEJNT\",\"WARC-Block-Digest\":\"sha1:TMNADSH5KVJQGVZPPDKPZ3QDXD5J26ZO\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-50/CC-MAIN-2020-50_segments_1606141747774.97_warc_CC-MAIN-20201205104937-20201205134937-00194.warc.gz\"}"}