Help Manual


Sigma Magic Help Version 17

K-Means Clusters Analysis


This analysis can be used to determine the clusters using the K-means method. K-means clustering is an unsupervised learning algorithm that clusters data based on similarity. Unsupervised learning means that there is no outcome to be predicted, and the algorithm tries to find patterns in the data. You need to specify the number of clusters to extract. However, a plot of the within-group sum of squares by the number of clusters extracted can help determine the appropriate number of clusters. The algorithm reassigns data points to the clusters whose centroid is the closest. It then re-calculates the new centroid of each cluster and repeats the process until the within-cluster variation cannot be reduced any further. The within-cluster variation is calculated as the sum of the Euclidean distance between the data points and their cluster centroids.

This functionality is provided by the R software using the function kmeans from package stats. Note that this functionality requires that RScript software be installed on your computer and linked to the Sigma Magic software within the options menu. K-Means Cluster Analysis worksheet can be added to your active workbook by clicking on Analytics and then selecting Cluster Analysis > K Means.


Click on Analysis Setup to open the menu options for this tool. A sample screenshot of the menu is shown below.
menu 1
Algorithm: Specify the algorithm to use for this analysis.
AutoThe default is Hartigan and Wong.
ForgyMinimizes the within sum of squares
Hartigan-WongMakes clever choices in checking for the closest cluster.
LloydMinimizes within cluster sum of squares. One of the simplest clustering algorithm.
MacQueenUpdates the two involved clusters if an object is moved.
Num Clusters: Specify the number of clusters extracted from the data set. If this value is set to Auto, the system will determine an appropriate number of clusters from the analysis.
Distance Metric: Specify the formula used to determine the distance between observations. Currently, only the Euclidean distance measure (the square distance between two vectors) is available.
Standardize: This specifies if the input observations should be standardized so that each variable has a similar variance structure.
Num Starts: Specify the number of random starts for initial cluster centers. This will enable the algorithm to try various combinations to arrive at the final cluster centers.
Max Iterations: Specify the maximum number of iterations before the algorithm will settle for the final solution. The larger the number of iterations, the longer the computation time.
Additional Options: This field is optional. By typing it here, you can specify any additional options for the R software program.
Help Button: Click on the Help Button to view the help documentation for this tool.
Cancel Button: Click on the Cancel Button to discard your changes and exit this menu.
OK Button: Click on the OK Button to save your changes and try to execute the program. You must specify the required data to complete the analysis and generate outputs. If there are any missing data, the software will remind you to specify the data and click on Compute Outputs to generate analysis results.


You will see the following dialog box if you click the Data button. Here, you can specify the data required for this analysis. Data
Search Data: The available data displays all the columns of data that are available for analysis. You can use the search bar to filter this list and speed up the search for the right data for analysis. Enter a few characters in the search field, and the software will filter and display the filtered data in the Available Data box.
Available Data: The available data box contains the list of data available for analysis. If your workbook has no data in tabular format, this box will display "No Data Found." The information displayed in this box includes the row number, whether the data is Numeric (N) or Text (T), and the name of the column variable. Note that the software displays data from all the tables in the current workbook. Even though data within the same table have unique column names, columns across different tables can have similar names. Hence, it is crucial that you not only specify the column name but also the table name.
Add or View Data: Click on this button to add more data to your workbook for analysis or to view more details about the data listed in the available data box. When you click on this button, it opens the Data Editor dialog box, where you can import more data into your workbook. You can also switch from the list view to a table view to see the individual data values for each column.
Required Data: The code for the required data specifies what data can be specified for that box. An example code is N: 2-4. If the code starts with an N, you must select only numeric columns. If the code begins with a T, you can select numeric and text columns. The numbers to the right of the colon specify the min-max values. For example, if the min-max values are 2-4, you must select a minimum of 2 columns of data and a maximum of 4 columns in this box. If the minimum value is 0, then no data is required to be specified for this box.
Select Button: Click on this button to select the data for analysis. Any data you choose for the analysis is moved to the right. To select a column, click on the columns in the Available Databox to highlight them and then click on the Select Button. A second method to choose the data is to double-click on the columns in the list of Available Data. Finally, you can drag and drop the columns you are interested in by holding down the select columns using your left mouse key and dragging and dropping them in one of the boxes on the right.
Selected Data: The list box header will be displayed in black if the right number of data columns is specified. If sufficient data is not specified, the list box header will be displayed in red. Note that you can double-click on any of the columns in this box to remove them from the box.
View Selection: Click on this button to view the data specified for this analysis. The data can be viewed either in the tabula format or you can view a graphical summary of the data selected.


If you click the Verify button, the software will perform some checks on the data you entered. A sample screenshot of the data is shown in this figure. Pre-Process Inputs 4
Verify Checks: The software checks if you have correctly specified the input options and if you have specified the data correctly for analysis.
Check Status: The results of the analysis checks are listed here. If the checks are passed, they are shown as a green checkmark. If the verification checks fail, they are shown as a red cross. If the verification checks result in a warning, they are shown in the orange exclamation mark. Finally, any checks that are required to be performed by the user are shown as blue info icons.
Overall Status: The overall status of all the checks for the given analysis is shown here. The overall status check shows a green thumps-up sign if everything is okay and a red thumps-down sign if any checks have not passed. Note that you cannot proceed with generating analysis results for some analyses if the overall status is not okay.


Click on Compute Outputs to update the results on the worksheet. A sample screenshot of the worksheet is shown below.
Kmeans Outputs
Notes Section: The notes section summarizes the input data, and the analysis results section shows the number of iterations, the number of observations within each cluster, and the sum of squares within the cluster overall.
Graph Section: The graph section shows the clusters identified and the observations grouped within each cluster. The second graph shows the reduction in variation of the sum of squares with the number of clusters. Look for a sharp bend in this graph to select the optimal number of clusters. According to the cluster plot, rows 1-3 are "similar," and 4-7 are "similar". The cluster numbers are shown in the output column.


Here are a few pointers regarding this analysis:
  • This analysis requires that the R software needs to be installed on your computer. Further, you will need to provide a link to the R Script executable file under Sigma Magic Options so that the software can use the R software to generate analysis results.


The following examples are in the Examples folder.
  • For the car data in the file (mtcars within R), determine the K-Means cluster analysis. Draw conclusions on which rows (cars) are similar. (Kmeans 1.xlsx).


For more information on this topic, please refer to the following articles. Do note that if any external links are mentioned below, they are for reference purposes only.

© Rapid Sigma Solutions LLP. All rights reserved.