K-means algorithm

Source: Internet
Author: User

K-means algorithminput Input:data Xoutput Output:data (x,s)Explanation: Input data X without a label, trained to add a label to each data s{s1,s2,..., SK}, the corresponding cluster center is U{U1,U2,..., UK}. effect: Divides the input data into K class and obtains the center point of its corresponding category. ========================================================================================
Step 1 Initializing Cluster center (U1,U2,..., UK)---Randomly selects K sample points from train data as the initial Clustering center (U1,U2,..., UK); --------------------------------------------------------------------------------------------------------------- --------------------------------------------
Step 2 for nearest neighbor collation and update of cluster center actions---According to the cluster center, traverse all the sample points, with the nearest neighbor principle (the sample point distance which cluster center near to which category), calculate the sample point and all cluster center point distance, select the minimum distance of the cluster center, and belong to that category; after the---cluster is finished, the cluster center is calculated again, and the average of all the sample points in the same class is calculated as a new cluster center. ----------------------------------------------------------------------------------------------------------- ------------------------------------------------
Step 3 Repeats step 2 until the convergence is not changed until the cluster changes. --------------------------------------------------------------------------------------------------------------- --------------------------------------------
the conditions for convergence are: s and u are no longer changed.
K-means theory derivation Process a contract: if x1≈x2, we can easily use U≈x1≈x2 Such a simple standard to cluster. using this convention we can get {s1,s2,..., Sk} on the DataSet X{xn}, and the corresponding choice U{U1,U2,..., UK}. so we can use the square error form of the cluster error to propose an optimization problem, its definition and derivation process as shown:The concrete derivation thought is the first fixed cluster center, optimizes the data classification, the method is the nearest neighbor thought; then the stationary classification, optimizes the cluster center to obtain the cluster center the optimal solution is the class average (mean) by the method of solving the gradient least; the solution of the optimization problem is often not one-step analysis, Most of the time, this is achieved by iterative recursion, which ultimately gives an iterative termination or recursive termination condition. The method of K-means is that the iterative termination condition is that the clustering no longer changes, which corresponds to the convergence of the algorithm. K-means Experimental Results
Results Analysis and Description: It can be seen that the K-means algorithm is a very effective clustering algorithm, usually need to pay attention to the random initialization of the location of the cluster and set the number of K, from the experimental results can be seen in the K-means algorithm is more sensitive to these initialization conditions.
*************************************************************************************************************** From the above analysis can be summarized, K-means algorithm is a relatively simple and effective clustering algorithm, in practical applications is a more popular and commonly used, and its specific code implementation should be simple and naïve. The core of the algorithm can be understood intuitively from the name of the algorithm.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

K-means algorithm

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.