Clustering data

Clustering groups the records in a table based on similar values in one or more numeric key fields. Similar values are values that are nearby or close to one another in the context of the entire data set. These similar values represent clusters that, once identified, reveal patterns in the data.

How clustering differs from other Analytics grouping commands

Clustering differs from other Analytics grouping commands:

  • Clustering does not require grouping on exact values, or predefined strata with hard numeric boundaries. Instead, clustering groups data based on similar numeric values – that is, values that are close or nearby to one another.
  • Clustering does not require pre-existing data categories.
  • Clustering based on more than one field outputs results that are not nested (non-hierarchical).

How the clustering algorithm works

Clustering in Analytics uses the K-means clustering algorithm, which is a popular machine learning algorithm. You can find detailed descriptions of K-means clustering on the Internet.

A summary of the algorithm appears below.

Choosing the number of clusters (K value)

Determining the optimal number of clusters to use when clustering data can require some testing and experimentation. For any given data set, there is not an exact answer.

Choosing the fields to cluster on

Clustering allows you to discover organic groupings in data that you may not know exist. You are free to create clusters based on multiple numeric fields. In this sense, clustering is exploratory, and an example of unsupervised machine learning.

However, in order to make sense of the output clusters, you need to understand the relation between the fields you select for clustering.

Can I cluster on character or datetime fields?

Generally, you cannot cluster on character or datetime fields. The clustering algorithm accepts only numbers, and it performs calculations with the numbers (Euclidean distance, mean).

Assessing the output clusters

The clustering algorithm will always output a table with the specified number of clusters. Every record in the output table will be in a cluster.

At this point, you need to assess whether any of the clusters have analytical significance or meaning. Just because the algorithm groups records in a cluster does not necessarily mean the grouping is significant.

Two characteristics you can assess are cluster coherence and cluster size.

Tip

Graphing the cluster output table as a scatter plot in a reporting tool, with each cluster assigned a different color, is the easiest way to quickly assess the nature of the output clusters.

Steps

Specify settings for the clustering algorithm

  1. Open the table with the data that you want to cluster.
  2. From the Analytics main menu, select Machine Learning > Cluster.
  3. In Number of clusters (K Value), specify the number of clusters to use for grouping the data.
  4. In Maximum number of iterations, specify an upper limit for the number of iterations performed by the clustering algorithm.
  5. In Number of initializations, specify the number of times to generate an initial set of random centroids.
  6. Optional. Select Seed, and enter a number.

Specify a data preprocessing method

In the Preprocessing dropdown list, select the method for preprocessing the data before clustering it:

Standardize Center key field values around zero (0), and scale the values to unit variance when calculating the clusters
Scale to unit variance Scale key field values to unit variance when calculating the clusters, but do not center the values around zero (0)
None Use the raw key field values, unscaled, when calculating the clusters

Select fields

  1. From the Cluster On list, select one or more key fields to use for clustering the records in the table.

    Key fields must be numeric.

  2. Optional. From the Other Fields list, select one or more additional fields to include in the output table.

Tip

You can Ctrl+click to select multiple non-adjacent fields, and Shift+click to select multiple adjacent fields.

Finalize command inputs

  1. If there are records in the current view that you want to exclude from processing, enter a condition in the If text box, or click If to create an IF statement using the Expression Builder.

    Note

    The If condition is evaluated against only the records remaining in a table after any scope options have been applied (First, Next, While).

    The IF statement considers all records in the view and filters out those that do not meet the specified condition.

  2. In the To text box, specify the name of the output table.
  3. Optional. On the More tab:
    1. To specify that only a subset of records are processed, select one of the options in the Scope panel.
    2. Select Use Output Table if you want the output table to open automatically.
  4. Click OK.
Analytics 14.1 Help