Types of Data in Cluster Analysis
Clustering algorithms depend on how similarity between objects is measured, which in turn depends on the type of data. This topic defines proximity measures for every data type, plus the key issue of standardising heterogeneous attributes.
1. Interval-Scaled (Numeric) Variables
Continuous measurements ( = value of object on attribute ).
Step 1 — Normalise to remove scale effects (so currency/km/age are comparable) using the z-score:
Step 2 — Distance measures between objects and :
Euclidean distance ():
Manhattan / city-block distance ():
Minkowski distance (general ):
Chebyshev / supremum ():
Weighted Euclidean (attribute weighting):
Note: is the limit of Minkowski as ; larger gives more weight to the largest difference.
Numerical example — , :
| 1 | 2 | 3 | ||
|---|---|---|---|---|
| distance | 7 | 5 | 4.497 | 4 |
Similarity from distance: , or use cosine similarity
Cosine is preferred for text/document vectors because it ignores magnitude.
2. Binary Variables
Symmetric binary (both outcomes equally important, e.g. gender):
Asymmetric binary (one outcome rarer/more meaningful — "1" usually means presence):
where = both 1, = =1 & =0, = =0 & =1, = both 0.
Jaccard similarity ; better than overall similarity when 0s dominate (sparse data).
Numerical example (name, gender, fever, cough, test-1..4 from the classic table; asymmetric attributes: fever, cough, t1-t4):
| Pair | q | r | s | Symmetric dist | Jaccard dist |
|---|---|---|---|---|---|
| Jack–Mary | 2 | 1 | 2 | (1+2)/6 = 0.50 | 3/5 = 0.60 |
| Jack–Jim | 1 | 2 | 1 | 3/6 = 0.50 | 3/4 = 0.75 |
| Jim–Mary | 1 | 1 | 2 | 2/6 = 0.33 | 2/4 = 0.50 |
3. Nominal (Categorical) Variables
Values from an unordered set with states. Simple matching:
Alternative: convert to asymmetric binary attributes (one-hot) and use Jaccard.
Example: (red, medium, A) vs (blue, medium, B) → , → .
4. Ordinal Variables
An ordinal value can be ranked but not metrically compared (e.g. small < medium < large, ranks 1..).
- Replace each value by its rank .
- Map the rank to [0,1]:
- Use any interval-scaled distance (e.g. Euclidean) on the transformed values.
Example: {fair, good, excellent} mapped to → good vs excellent: vs .
5. Ratio-Scaled Variables
Positive measurements on a non-linear scale (exponential growth/decay: bacterial population, radioactive decay). Apply a log transform first, then treat as interval-scaled:
6. Mixed Types of Variables
One distance that handles all types together. For attributes , with indicator if or is missing or when is asymmetric binary with both values 0, otherwise 1:
Per-attribute contribution:
| Type | |
|---|---|
| Interval-scaled | |
| Nominal | 0 if equal, 1 otherwise |
| Ordinal | |
| Ratio-scaled | distance on values, range-normalised |
| Binary | 0/1 (Jaccard style) |
Worked mixed example (test-1: nominal; test-2: ordinal with ; test-3: ratio etc.)
| Object | test-1 | test-2 | test-3 |
|---|---|---|---|
| A | code-A | excellent | 1.5e3 |
| B | code-B | fair | 2.5e4 |
| C | code-C | good | 1.3e5 |
- test-1 (nominal) contributes 1 for every pair (all different).
- test-2 (ordinal, ): excellent = 1, fair = 0, good = 0.5 → , , .
- test-3 (ratio, log = 3.18, 4.40, 5.11; range 1.93): , , .
7. Why the Data Type Matters
| Data type | Typical measure | Watch out for |
|---|---|---|
| Interval | Euclidean / Manhattan / cosine | Scale differences → normalise |
| Binary asymmetric | Jaccard | Dominance of 0s |
| Nominal | Simple matching / one-hot + Jaccard | High dimensionality after one-hot |
| Ordinal | Rank-normalised Euclidean | Assume monotone spacing |
| Ratio | Log-transform + interval | Zero/negative values |
| Mixed | Weighted general distance with | Missing values, attribute weighting |
8. Exam Points
- Explain proximity measures for interval, binary, nominal, ordinal and ratio variables — 10 marks (very frequent).
- Compute Euclidean, Manhattan, Minkowski and supremum distances for two points — 3-5 marks numerical.
- Compute Jaccard/simple matching distance from a table of binary attributes — 5 marks numerical.
- Explain the mixed-type distance formula with — 5-7 marks.
- Why is normalisation needed before clustering? — 3 marks.