美文网首页数据科学家每天写500字
What is k-means, How to set K?

What is k-means, How to set K?

作者: 不会停的蜗牛 | 来源:发表于2019-07-20 23:46 被阅读57次

    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

    相关文章

      网友评论

        本文标题:What is k-means, How to set K?

        本文链接:https://www.haomeiwen.com/subject/sxvplctx.html