Weka_ Cluster Analysis Example Walkthrough

Source: Internet
Author: User
Tags numeric random seed
Weka_ Cluster Analysis Example Walkthrough1. Data preparation: Download link http://download.csdn.net/detail/xuxurui007/6753847
2, the principle of clusteringThe "Class" (cluster) in cluster analysis is different from the "class" in the preceding category, and a more accurate translation of cluster should be "cluster".The task of clustering is to assign all instances to a number of clusters, so that instances of the same cluster are clustered around a cluster center, and the distances between them are relatively near, and the distance between the different cluster instances is far away.      For instances characterized by numeric attributes, this distance usually refers to Euclidean distance. We now use the most common K-mean (K-means) algorithm for cluster analysis of the "bank data" in front of us.           Here we briefly describe the K-mean clustering steps: 1 K-Mean algorithm first randomly designated K Cluster Center, 2) Each instance is assigned to its nearest cluster center, get k clusters, 3) calculate the mean value of all instances in each cluster, and use them as the new cluster center.      4) Repeat 1) and 2) until the location of the center of the K cluster is fixed, and the distribution of the cluster is fixed. The K-mean algorithm above can only handle numeric properties, and when it encounters a property of a type, it changes to a number of properties that take values 0 and 1.Weka will automatically implement this type-to-numeric transformationAndWeka automatically standardizes numerical data。 The resulting data file is "Bank.arff" and contains 600 instances.
3. Implementation steps(1)Use "explorer" to open the "Bank.arff" You just Got (600 instance Data)。



(2)Switch to "Cluster" and click "Choose" button to select "Simplekmeans", which is the algorithm to implement K-means in Weka.
(3)Click the next text box, modify the "Numclusters" to 6, indicating that we want to put these 600 instances into 6 classes, namely k=6; The following "seed" parameter is to set a random seed, which produces a random number, which is used to get the location of the K-cluster center given in the K-means algorithm for the first time. We might as well just let it be 10, click OK.
(4)Select "Use training set" of "Cluster Mode" (using training Set), choose "Store Clusters for visualization" (Storage cluster visualization), click "Start" button.

(5)Observe the cluster results given by the right "clusterer output". You can also right-click on the result from the "result list" in the lower left corner and "View in separate window" to browse the results in a new pane.


3. Analysis of results (1)First we notice that there is such a line in the result (Error squared sum): Within cluster sums of squared errors:1604.7416693522332 This is the standard for evaluating the quality of clustering, the smaller the value of the descriptionSame clusterThe smaller the distance between instances.

actuallyIf you change the "seed" parameter, the resulting value may be different,For example take "seed" to, you get: Within cluster sum of squared errors:1555.6241507629218

(Perhaps the actual value is not the same) should take this back, of course, try a few seed, this value may be smaller (the smaller the number, the smaller the distance of the same cluster instance, the better the result of clustering.) Multiple experiments to find the value tends to be the smallest value (the larger the instance capacity, the more difficult), that is, the best results of the experiment.
(2)The next "Cluster centroids:" Lists the locations of each cluster center.for a numeric attribute, the cluster center is its mean value (Mean)The number of types is its majority (Mode), which means that the attribute is valued as the value of theinstances up to。 For the properties of the numerical type, the standard deviation (Std Devs) in each cluster is also given.
(3)The Last "Clustered Instances"Isthe number and percentage of instances in each cluster.
(4)To observe the visual clustering results, right-click on the results listed in the bottom left "result list" and click "Visualize cluster Assignments”。 
The popup window gives aScatter plots for each instance。 The top two boxes are select horizontal and ordinate, the second row of "color" is the basis for scatter plot coloring, by default, according to different clusters "Cluster" to the instance of different colors. You can save the cluster result as a Arff file here by clicking "Save".


in this new Arff file, the "Instance_number" attribute represents the number of an instance, and the "Cluster" attribute represents the cluster in which the instance is given by the clustering 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.