---
title: "Measuring similarity between data"
subject: "Data Mining"
chapter: 2
key: "semester_7/data_mining:similarity-measures"
source: https://www.bctengineer.com/q/semester_7/data_mining/similarity-measures
site: BCT Engineering
---

# Measuring similarity between data

Data Mining · Chapter 2: Data Pre-processing

- Asked in: year not given
- Video: [How to find Euclidean Manhattan Minkowski distance Supremum distance Cosine Similarity Mahesh Huddar](https://www.youtube.com/watch?v=gwtTM9M6ugU) — Mahesh Huddar
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/data_mining/similarity-measures
- Whole chapter: https://www.bctengineer.com/md/semester_7/data_mining/chapter-2

## Question

What are the approaches to measure similarity between data?

## Short answer

Similarity is measured by distance for numeric data (Euclidean, Manhattan, cosine), matching coefficients for binary (Jaccard, simple matching) and nominal attributes, and rank normalization for ordinal. Mixed attributes use weighted combination; normalization prevents range dominance.

## Answer

**Similarity** measures how alike two objects are (usually 0 to 1; larger = more alike). **Dissimilarity/distance** measures how different they are (minimum often 0). The choice depends on the attribute type.

#### Numeric attributes (distance measures)
For objects x = (x₁…xₙ) and y = (y₁…yₙ):
- **Euclidean**: d = √Σ(xᵢ − yᵢ)²
- **Manhattan**: d = Σ|xᵢ − yᵢ|
- **Minkowski**: d = (Σ|xᵢ − yᵢ|ʰ)^(1/h) (h = 1 Manhattan, h = 2 Euclidean, h = ∞ Chebyshev/supremum)
- **Cosine similarity**: cos(x, y) = (x·y)/(‖x‖‖y‖), used for documents.
- **Correlation coefficient** for linear relation between two objects.
- **Mahalanobis distance** takes account of correlation between attributes.
Attributes should be normalised first so that one large-range attribute does not dominate.

#### Binary attributes
Using counts q (1,1), r (1,0), s (0,1), t (0,0):
- **Simple matching coefficient (SMC)** = (q + t)/(q + r + s + t) for symmetric attributes
- **Jaccard coefficient** = q/(q + r + s) for asymmetric attributes (ignores 0-0 matches)

#### Nominal attributes
Simple matching: d = (p − m)/p, where m = number of matching attributes and p = total attributes.

#### Ordinal attributes
Replace ranks by (r − 1)/(M − 1), a value from 0 to 1, then use a numeric distance.

#### Mixed attributes
Weighted combination of the per-attribute distances (Gower's measure).

#### Other
Edit distance for strings, Tanimoto/extended Jaccard, KL divergence for distributions.

*Example*: x = (1, 2), y = (4, 6): Euclidean = √(9 + 16) = 5; Manhattan = 3 + 4 = 7.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Minkowski distance with h = 1 and h = 2 equals?
   A. Euclidean and Manhattan
   B. Manhattan and Euclidean
   C. Chebyshev and Manhattan
   D. Cosine and Jaccard
   Answer: B. h = 1 gives Manhattan, h = 2 Euclidean, h = infinity supremum. (Key point: Minkowski)

2. When is Jaccard used instead of SMC?
   A. For symmetric binary attributes
   B. For numeric attributes
   C. For asymmetric binary attributes, ignoring 0-0 matches
   D. For ordinal attributes
   Answer: C. Jaccard = q/(q + r + s) excludes t. (Key point: Jaccard vs SMC)

3. For which data is cosine similarity typically used?
   A. Temperature readings
   B. Nominal attributes
   C. Single numbers
   D. Documents
   Answer: D. cos = (x.y)/(||x|| ||y||) works on sparse word-count vectors. (Key point: Cosine similarity)

4. For x = (1, 2), y = (4, 6), the Euclidean and Manhattan distances are?
   A. 5 and 7
   B. 7 and 5
   C. 25 and 7
   D. 5 and 5
   Answer: A. Euclidean = sqrt(9 + 16) = 5; Manhattan = 3 + 4 = 7. (Key point: Numeric example)

## Related in Data Mining

- [Lift measure with example](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Alift-measure) — Data Mining, chapter 4
- [Major clustering approaches](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aclustering-approaches) — Data Mining, chapter 5
- [Graphical drawbacks; statistical approaches](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aanomaly-graphical-statistical) — Data Mining, chapter 6
- [Data cleaning: missing, noisy, outliers](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Adata-cleaning) — Data Mining, chapter 2

## Related in other subjects

- [Device to measure 7.5 mW microwave power](https://www.bctengineer.com/question.md?key=semester_7%2Frf_and_microwave_engineering%3Ameasure-7-5mw-power) — RF and Microwave Engineering, chapter 8
- [Measuring pressure difference in a pipe](https://www.bctengineer.com/question.md?key=semester_6%2Fhydro_power%3Ameasuring-pressure-difference) — Hydro Power, chapter 1
- [Mid-section method discharge from current meter data](https://www.bctengineer.com/question.md?key=semester_5%2Fengineering_hydrology%3Amidsection-0-3n-0-004) — Engineering Hydrology, chapter 4
- [Correction per tape length (kgf data, 61)](https://www.bctengineer.com/question.md?key=semester_3%2Fsurveying_i%3Atape-base-line-correction-per-tape-61) — Surveying I, chapter 2, asked 2×
