Tutorials › Exam PA - Predictive Analytics › Resampling To Assess Cluster Stability

Exam PA · Clustering and Similarity Structure · Tutorial 605 of 966

Resampling To Assess Cluster Stability

Use resampling to measure how consistently clustering methods recover the same groups when the observed data are perturbed.

Intermediate 12 min read

What You'll Learn

  • Distinguish bootstrap resampling from subsampling for cluster stability analysis
  • Compare clusters across fits when cluster labels can switch
  • Calculate matched Jaccard overlap and case-level assignment consistency
  • Use pairwise co-assignment rates without matching cluster labels
  • Interpret stability measures alongside the clustering procedure and its limitations

Why Assess Cluster Stability?

A clustering algorithm always produces groups from the data supplied to it, but that fact alone does not show that the groups are persistent. Small changes in the observed records may change the memberships substantially. Resampling assesses this sensitivity by fitting the clustering procedure repeatedly to perturbed versions of the data and comparing the resulting assignments.

This is a question about stability, not proof that a set of groups is objectively true. A cluster solution can be stable but not useful for the business problem, and an unstable solution may reflect genuine overlap or limited information in the available data. Stability is one diagnostic to report alongside the clustering method, its inputs, and any relevant internal indices.

Definition: Cluster stability is the extent to which a clustering procedure recovers similar groups or assignments when the data are perturbed by resampling. A stability calculation must specify the perturbation, how clusters from different fits are compared, and which observations are included in that comparison.

Resampling Designs and What Gets Compared

In a bootstrap, a resample of size \(n\) is drawn with replacement from \(n\) observed records. A record can appear more than once or not appear at all in a particular resample. In subsampling, a specified number of records is drawn without replacement, so no record is duplicated within a resample. The resampling scheme should be chosen and described before interpreting stability.

Each resample is clustered using the same preprocessing decisions, distance measure, clustering method, and number of clusters as the reference fit. If the aim is to evaluate whether a chosen cluster count is stable, hold that count fixed during this comparison. Changing it across fits makes it harder to separate membership sensitivity from changes in the number of groups.

The comparison also needs a defined set of observations. One option is to compare assignments only for records present in both fits. Another is to fit on each resample and then assign all original records using a defined extension of that clustering method, such as assignment to the nearest fitted \(k\)-means centroid. That extension is not available for every method. For methods without a natural assignment rule for new records, compare only the shared records or state a justified alternative explicitly.

Bootstrap resamples contain duplicate copies of some records. If a method or comparison treats copies as separate observations, their repeated presence can affect the fitted clusters. A report should state how duplicates are handled and should not silently treat a bootstrap fit as if every original record appeared exactly once. Subsampling avoids within-resample duplicates, but a record omitted from a fit cannot contribute a membership comparison for that fit unless an assignment rule is defined.

1
Fix the analysis choices.
Specify the variables, preprocessing, distance, clustering method, and number of clusters. Keep these choices consistent across resamples unless their sensitivity is itself the question.
2
Generate perturbed data sets.
Use a stated bootstrap or subsampling design. Record which observations occur in each resample and how duplicate bootstrap copies are treated.
3
Fit and define comparability.
Cluster each resample, then determine the common observations or the explicit method used to assign observations not included in a fit.
4
Compare memberships and summarize.
Match cluster labels when using cluster-wise overlap, or use a label-invariant measure such as pairwise co-assignment. Report the denominator and summarize variation across resamples.

Matching Clusters Across Fits

Cluster labels such as “cluster 1” and “cluster 2” are arbitrary. A fit that calls a group cluster 1 and another fit that calls the same group cluster 2 has not changed its memberships. Therefore, compare sets of observations, not the numeric labels themselves.

For a reference cluster \(C\) and a cluster \(D\) from a resampled fit, their Jaccard overlap is the number of shared observations divided by the number appearing in either cluster. It ranges from 0, for no shared observations, to 1, for identical sets.

$$ J(C,D)=\frac{|C\cap D|}{|C\cup D|} $$

With multiple clusters, match clusters across the two fits to maximize total overlap, typically using the one-to-one matching with the largest sum of Jaccard values. This prevents a reference cluster from being matched independently to several resampled clusters. If the number of clusters differs, any unmatched cluster needs an explicit treatment; do not imply that a one-to-one comparison covers all groups.

A cluster-level stability summary can be the mean matched Jaccard value for that reference cluster across resamples. The average should be accompanied by the number of usable comparisons and, where informative, the range or distribution of values. An average alone can conceal a cluster that is stable in most fits but fails in a few.

Worked Example: Matching Two Clusters Across Bootstrap Fits

Six hypothetical claim records, A through F, are used for a two-cluster solution. A reference fit has \(C_1=\{A,B,C\}\) and \(C_2=\{D,E,F\}\). Four bootstrap fits each draw five records with replacement from the six records. For this illustration, each fitted solution is also used to assign all six original records by nearest fitted centroid, so every displayed partition covers A through F. The resulting partitions, with labels written as sets rather than cluster numbers, are:

  • Fit 1: \(\{A,B,C\}\), \(\{D,E,F\}\)
  • Fit 2: \(\{A,B,D\}\), \(\{C,E,F\}\)
  • Fit 3: \(\{A,C\}\), \(\{B,D,E,F\}\)
  • Fit 4: \(\{A,B,C,D\}\), \(\{E,F\}\)

Method. For each fit, calculate Jaccard overlaps between the two reference clusters and the two fitted clusters, then select the one-to-one matching with the greatest total overlap.

Fit 1. Both fitted groups equal their reference groups, so the two matched overlaps are \(3/3=1\) and \(3/3=1\).

Fit 2. The overlap of \(C_1\) with \(\{A,B,D\}\) is \(|\{A,B\}|/|\{A,B,C,D\}|=2/4=0.5\). The overlap of \(C_2\) with \(\{C,E,F\}\) is \(|\{E,F\}|/|\{C,D,E,F\}|=2/4=0.5\). These form the best one-to-one match; the two cross-matches each have overlap \(1/5=0.2\).

Fit 3. The overlap of \(C_1\) with \(\{A,C\}\) is \(2/3\). The overlap of \(C_2\) with \(\{B,D,E,F\}\) is \(3/4\). These are the best one-to-one match, for a total of \(2/3+3/4=17/12\).

Fit 4. The overlap of \(C_1\) with \(\{A,B,C,D\}\) is \(3/4\). The overlap of \(C_2\) with \(\{E,F\}\) is \(2/3\). These are the best one-to-one match.

The mean matched overlap for \(C_1\) is \((1+0.5+2/3+0.75)/4=35/48\), or 0.7292 to four decimals. For \(C_2\), it is \((1+0.5+0.75+2/3)/4=35/48\), also 0.7292. The arithmetic confirms that the two reference clusters have the same mean in this example. The common mistake is matching by the printed cluster number; the correction is to match memberships by overlap.

Assignment Consistency for Individual Observations

A different summary asks how often each record remains in its reference cluster. First align the cluster labels in every fit to the reference solution, using a stated matching procedure. For observation \(i\), let \(B_i\) be the resamples in which a comparable assignment for \(i\) is available, and let \(M_i\) be the number of those assignments that agree with its reference cluster after alignment. Its assignment consistency is \(M_i/|B_i|\).

This value is defined only relative to the chosen reference and comparison rule. If an observation is absent from some subsamples and has no out-of-sample assignment rule, those resamples are excluded from its denominator. Reporting only a consistency value without that denominator can be misleading: a value based on two usable fits is less informative than the same value based on many.

Worked Example: Calculating Case-Level Assignment Consistency

A reference clustering assigns records A, B, and C to group X, and D and E to group Y. After matching labels to the reference in each resampled fit, the available assignments are shown below. “Absent” means that no assignment was defined for that record in that fit.

RecordReferenceFit 1Fit 2Fit 3Fit 4
AXXXXY
BXXXYX
CXXYXX
DYYYYY
EYYAbsentYY

For A, three of four available fits assign X, so consistency is \(3/4=0.75\). B also has \(3/4=0.75\), and C has \(3/4=0.75\). D agrees in all four fits, giving \(4/4=1\). E agrees in all three fits where an assignment is available, giving \(3/3=1\); its denominator is three, not four.

The unweighted mean across the five records is \((0.75+0.75+0.75+1+1)/5=4.25/5=0.85\). This average describes this particular set of cases and denominators. It should not replace the individual values: for example, the three records in group X are less consistent than D and E.

Pairwise Co-Assignment and Why It Is Label-Invariant

Pairwise co-assignment asks whether two observations are placed in the same cluster, without requiring cluster labels to be matched. For a pair \(i,j\), calculate the proportion of usable resampled fits in which both observations can be compared that place them together. A fit contributes to the denominator only if the comparison is defined for both observations.

$$ \widehat{p}_{ij} = \frac{\sum_{b=1}^{B} I_{bij}}{N_{ij}} $$

Here \(I_{bij}=1\) when fit \(b\) places \(i\) and \(j\) in the same cluster, and \(I_{bij}=0\) when it places them in different clusters. \(N_{ij}\) is the number of fits in which both observations have comparable assignments. This measure is unchanged if a fit renames its clusters, because it uses only the same-cluster relationship.

The justification is direct. Imagine independently generating resamples under the chosen resampling design and fitting the fixed clustering procedure each time. For each usable fit, \(I_{bij}\) records whether the pair is grouped together. If the probability of this event under that design is \(p_{ij}\), then each indicator has expectation \(E[I_{bij}]=p_{ij}\). For \(N_{ij}\) independent usable fits with the same design, the average indicator has expectation

$$ E\left[\frac{1}{N_{ij}}\sum_{b=1}^{N_{ij}} I_{bij}\right] = \frac{1}{N_{ij}}\sum_{b=1}^{N_{ij}}E[I_{bij}] = \frac{1}{N_{ij}}(N_{ij}p_{ij}) = p_{ij}. $$

Thus the observed co-assignment rate is the natural empirical estimate of the probability that the pair is grouped together under repeated perturbations of this kind. This interpretation depends on a consistent resampling design and comparable fits; it is not a probability that the pair belongs to a “true” cluster.

Worked Example: Building Pairwise Co-Assignment Rates

Four records A, B, C, and D are compared in four resampled fits, each of which assigns all four records. The partitions are: Fit 1, \(\{A,B\}\) and \(\{C,D\}\); Fit 2, \(\{A,B\}\) and \(\{C,D\}\); Fit 3, \(\{A,C\}\) and \(\{B,D\}\); Fit 4, \(\{A,B,C\}\) and \(\{D\}\).

Method. For each of the six pairs, count the fits in which the pair is together and divide by four.

  • A and B are together in Fits 1, 2, and 4: \(3/4=0.75\).
  • A and C are together in Fits 3 and 4: \(2/4=0.50\).
  • A and D are together only in Fit 4? No: D is alone in Fit 4, and is separated from A in Fits 1, 2, and 3. Their rate is \(0/4=0.00\).
  • B and C are together only in Fit 4: \(1/4=0.25\).
  • B and D are together only in Fit 3? In Fit 3 they are together in \(\{B,D\}\), so the rate is \(1/4=0.25\).
  • C and D are together in Fits 1 and 2: \(2/4=0.50\).

The mean of the six pairwise rates is \((0.75+0.50+0+0.25+0.25+0.50)/6=2.25/6=0.375\). The individual rates are more informative than this single average: A and B are often grouped together, while A and D are never grouped together. The calculation also illustrates why the denominator and the fit partitions must be checked pair by pair.

Interpreting Stability and Avoiding Common Traps

Resampling stability is conditional on the entire analysis procedure. Different preprocessing, distance calculations, clustering algorithms, or resampling designs can produce different stability results. If stability is low, investigate whether particular records move between groups, whether a cluster repeatedly splits or merges, and whether the instability is concentrated in a small number of observations. Do not infer a cause from a stability score alone.

A common exam trap is to mistake cluster label switching for instability. Suppose a reference fit has \(\{A,B\}\) and \(\{C,D\}\), while a resampled fit reports “cluster 1” as \(\{C,D\}\) and “cluster 2” as \(\{A,B\}\). The memberships are identical: the correct matched Jaccard values are both 1. A comparison of numeric labels would incorrectly count all four assignments as changed.

Another mistake is to calculate overlap using the intersection divided by the size of just one cluster. That quantity is not Jaccard overlap and can be asymmetric. For example, if \(C=\{A,B,C\}\) and \(D=\{A,B,D\}\), their intersection has size 2 and their union has size 4, so the Jaccard value is \(2/4=0.5\). Dividing by \(|C|=3\) gives \(2/3\), which is a different measure and changes if the roles of \(C\) and \(D\) are reversed.

Finally, a high stability score does not establish predictive performance, causal meaning, or practical value. It only indicates that similar assignments were recovered under the stated perturbations and procedure. In a report aligned with the SOA Exam PA (Predictive Analytics) syllabus, describe what was resampled, how labels or observations were compared, how many comparisons were usable, and what the results do and do not support.

Key takeaway: Assess stability by repeatedly perturbing the data and comparing memberships with a method that handles arbitrary cluster labels. Matched Jaccard overlap summarizes cluster similarity, case-level consistency summarizes assignment persistence, and pairwise co-assignment avoids label matching altogether. Always state the comparison set and denominator.

Check Your Understanding

For each problem, identify the comparison being made and check the denominator before calculating.

  1. A reference cluster is \(\{P,Q,R\}\), and a cluster from one resampled fit is \(\{P,Q,S\}\). What is their Jaccard overlap? (Answer: \(2/4=0.5000\))
  2. Two records have comparable assignments in eight resampled fits and are placed together in five. What is their pairwise co-assignment rate? (Answer: \(5/8=0.6250\))
  3. A reference solution is \(\{A,B\}\), \(\{C,D\}\). After optimal matching, Fit 1 has Jaccard values \(1/3\) for each reference cluster, and Fit 2 has values 1 for each. What is the mean matched Jaccard value for either reference cluster across the two fits? (Answer: \((1/3+1)/2=2/3\))
  4. Across five usable fits, records U and V are together in four. In one additional fit, V is absent and no assignment is defined. What is their co-assignment rate? (Answer: \(4/5=0.8000\); the fit without a comparable pair is excluded.)
  5. A record agrees with its reference cluster in six of eight fits where an assignment is available. It is absent without an assignment in two other fits. What is its assignment consistency, and what denominator should be reported? (Answer: \(6/8=0.75\), with denominator 8 usable assignments.)
Clinical Biostats