---
title: "\"Do as your Neighbor Do\" principle"
subject: "Data Mining"
chapter: 3
key: "semester_7/data_mining:neighbor-do-likelihood-distance"
source: https://www.bctengineer.com/q/semester_7/data_mining/neighbor-do-likelihood-distance
site: BCT Engineering
---

# "Do as your Neighbor Do" principle

Data Mining · Chapter 3: Classification

- Asked in: 2066 Bhadra, 4+2 marks
- Video: [k nearest neighbor algorithm | k nearest neighbor classifier  | data mining | knn algorithm](https://www.youtube.com/watch?v=iCJmTYu6Inw) — NS lectures
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/data_mining/neighbor-do-likelihood-distance
- Whole chapter: https://www.bctengineer.com/md/semester_7/data_mining/chapter-3

## Question

"Do as your Neighbor Do". Explain this concept on behalf of Likelihood and Distance principle. Differentiate between hierarchical clustering and partitioning clustering technique.

## Short answer

"Do as your neighbour does" means nearest-neighbor classification: assign class by majority of closest objects, using distance to measure similarity and likelihood to choose class. Hierarchical clustering creates a tree of nested clusters without presetting k, O(n²); partitioning (k-means) splits into k groups iteratively, faster but requires spherical clusters.

## Answer

#### "Do as your neighbour does" and the likelihood-and-distance principle
This phrase means that an object behaves like the objects nearest to it. Under the **distance** principle, objects close to each other in attribute space are similar and likely to share the same class or cluster; under the **likelihood** principle, the class most probable among its neighbours is assigned to the object.

This is the idea of **K-nearest neighbour (KNN)**:
1. Compute the distance (e.g. Euclidean) from the new object to every stored object.
2. Choose the K nearest ones (its "neighbours").
3. Assign the majority class of these neighbours (or their average, for prediction).

*Example*: a customer whose 3 nearest customers (by age and income) all bought a laptop is predicted to buy a laptop too. The same idea clusters data: an object joins the cluster of the centre it is nearest to.

#### Hierarchical vs partitioning clustering
| Basis | Hierarchical | Partitioning |
| --- | --- | --- |
| Result | Nested clusters shown as a tree (dendrogram) | One flat set of k non-overlapping clusters |
| Number of clusters k | Not needed in advance; choose by cutting the dendrogram | Must be given in advance |
| Method | Agglomerative (bottom-up) or divisive (top-down) | Iterative relocation (k-means, k-medoids) |
| Merge/split | Once done, cannot be undone | Objects can move between clusters in later iterations |
| Complexity | At least O(n²), poor for big data | About O(nkt), good for big data |
| Cluster shape | Can find arbitrary shapes (with single link) | Tends to find spherical clusters |
| Examples | AGNES, DIANA, BIRCH | k-means, k-medoids (PAM) |

## Check yourself

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

1. What does "Do as your neighbour does" mean in data mining?
   A. An object behaves like the farthest objects
   B. An object behaves like the cluster mean of all data
   C. An object's class is chosen randomly from all classes
   D. An object is assumed to behave like the objects nearest to it
   Answer: D. It is the KNN idea: close objects share the class. (Key point: Meaning of the phrase)

2. Which is the correct KNN procedure?
   A. Compute distances to all stored objects, take the K nearest, assign their majority class
   B. Pick K random objects and take their majority class
   C. Compute distances, take the K farthest, assign their majority class
   D. Build a dendrogram and cut it at K
   Answer: A. KNN uses the K nearest neighbours' majority class (or average for prediction). (Key point: KNN steps)

3. Which statement is true about the number of clusters k?
   A. It is required in advance for hierarchical but not partitioning
   B. In hierarchical clustering it need not be given in advance; in partitioning it must be
   C. It is required in both
   D. It is required in neither
   Answer: B. Hierarchical clustering gives a dendrogram that can be cut; k-means needs k. (Key point: Choosing k)

4. How do the two clustering types differ in merge/split decisions?
   A. Hierarchical lets objects move; partitioning cannot
   B. Neither can be revised
   C. Hierarchical merges/splits cannot be undone; partitioning lets objects move between clusters
   D. Both can be freely undone
   Answer: C. Partitioning relocates objects iteratively; hierarchical steps are final. (Key point: Reversibility)

## Related in Data Mining

- [Need of clustering; hierarchical vs partitioning; K-means](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Acluster-need-hier-vs-partition-kmeans) — Data Mining, chapter 5
- [Short note: Partitioning and hierarchical clustering](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Apartition-hierarchical-clustering-note) — Data Mining, chapter 5
- [DM techniques; likelihood and distance principle](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Adm-techniques-close-data-alike) — Data Mining, chapter 3
- [Short note: Likelihood and distance](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Alikelihood-distance-note) — Data Mining, chapter 3
- [Hierarchical clustering: AGNES and DIANA](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aagnes-diana) — Data Mining, chapter 5
- [Short note: Hierarchical clustering](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Ahierarchical-clustering-note) — Data Mining, chapter 5
