# What is k-means, How to set K?

### What is K-means?

figure cited here, recommend reading: K-Means Clustering – What it is and How it Works

K-means is a clustering algorithm, so it's one of the unsupervised machine learning algorithms.

This algorithm aims to group the data into K clusters.

Firstly, we predefine a K, and choose K data points arbitrarily as the centers of K clusters.

Secondly, for each data, we calculate its distances with the K centers. Select its nearest center and distribute it to this cluster.

Thirdly, after distributing all the data points, we compute the new centers within each cluster.

Then iterate step 2 and 3 until the centers are no longer change.

In a word, K-means is to get K clusters, use means to calculate the centers, and assign each sample to its nearest center.

### How to set K?

Start with k equals to 1, and calculate its variation which is the worst. Then try k equals to 2, and compare its variation with k=1. ... Each time we increase k, the total variation is smaller than before. Let's plot the reduction in variance per value for k, and find the largest reduction point, like an elbow. For example, this figure shows that when k=3, the variation has the hugest reduction, so we can set k equals to 3.

figure cited here, recommend reading: StatQuest: K-means clustering

0 条评论

• ### 面试官怎么看你的Github profile

Udacity的Machine Learning纳米学位课程中，关于Github的笔记。 听课范围： Github Profile Git 和 Github...

• ### 无人驾驶车

Sebastian Thrun: Google's driverless car 因为朋友在一场车祸中去世，就决定致力一生于自动驾驶车的研究，想要拯救更多的生命...

• ### What is PCA ?

figure cited here, recommend reading: A step by step explanation of Principal Co...

• ### Application Architecture Guide 2.0 - CH 19 - Mobile Applications（2）

本文翻译“Authentication and Authorization”、“Caching”、“Communication”和“Configuration ...

• ### 在DataGrid中选择,确认,删除多行复选框列表

在DataGrid中选择,确认,删除多行复选框列表 Selecting, Confirming & Deleting Mul...

• ### Speeding up AngularJS apps with simple optimizations

AngularJS is a huge framework with that already has many performance enhancement...

• ### 【译】（数字化）平台思维的艺术

作者: Amit Kaul (Vice President, Emerging Technology) & Ryan Murray (Director, Dig...

• ### BERT文本摘要

你有没有曾经需要把一份冗长的文件归纳成摘要？或者为一份文件提供一份摘要？如你所知，这个过程对我们人类来说是乏味而缓慢的——我们需要阅读整个文档，然后专注于重要的...

• ### ROS机器人项目开发11例-ROS Robotics Projects（6）Matlab和Android

书中，第8章主要介绍了ROS与Matlab和Android的接口，以及集成使用的方法。