- Year not given · 2+10 marks
K-nearest neighbor on student table
Short answer
K-nearest neighbor (KNN) is a lazy classifier that finds the K closest training records by distance and assigns the majority class. Using Euclidean distance on Std1 (22,53), the two nearest students are Std3 (20,54) and Std4 (24,52) with distance 2.236 each.
What is K-nearest neighbor? Find the other two students with common behavior from any one record of the following table (apply likelihood and distance principle).
| Name | Age | Weight |
|---|---|---|
| Std1 | 22 | 53 |
| Std2 | 26 | 57 |
| Std3 | 20 | 54 |
| Std4 | 24 | 52 |
K-nearest neighbour (KNN)
KNN is a lazy, instance-based classifier. To classify (or find similar objects for) a new object, it computes the distance to all stored objects, picks the K nearest and assigns the majority class of those neighbours. It rests on the likelihood and distance principle: close objects behave alike.
Solution
Take Std1 = (22, 53) as the given record and find its two nearest students using Euclidean distance d = √[(Age₁ − Age₂)² + (Weight₁ − Weight₂)²]. Here K = 2.
| Student | (Age, Weight) | Calculation | Distance to Std1 |
|---|---|---|---|
| Std2 | (26, 57) | √(4² + 4²) = √32 | 5.657 |
| Std3 | (20, 54) | √(2² + 1²) = √5 | 2.236 |
| Std4 | (24, 52) | √(2² + 1²) = √5 | 2.236 |
Sorting by distance: Std3 (2.236) and Std4 (2.236) are nearest; Std2 (5.657) is far.
Answer: the two students with behaviour most common to Std1 are Std3 and Std4.
For completeness, the full distance matrix:
| Std1 | Std2 | Std3 | Std4 | |
|---|---|---|---|---|
| Std1 | 0 | 5.657 | 2.236 | 2.236 |
| Std2 | 5.657 | 0 | 6.708 | 5.385 |
| Std3 | 2.236 | 6.708 | 0 | 4.472 |
| Std4 | 2.236 | 5.385 | 4.472 | 0 |
Taking another record as the query gives: for Std2 the nearest two are Std4 (5.385) and Std1 (5.657); for Std3 they are Std1 (2.236) and Std4 (4.472); for Std4 they are Std1 (2.236) and Std3 (4.472). Age and weight have similar ranges here, so no normalisation was required.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- DM techniques; likelihood and distance principle · Data Mining, chapter 3
- Rote-learner and K-nearest neighbor · Data Mining, chapter 3
- "Do as your Neighbor Do" principle · Data Mining, chapter 3
- Short note: Likelihood and distance · Data Mining, chapter 3
- Likelihood and distance; K-means drawbacks · Data Mining, chapter 3
- 96 students record; pass marks · Computer Programming, chapter 10
- Student records with two functions · Computer Programming, chapter 8
- Pass student array; display passed students · Computer Programming, chapter 7
- Mat 18 m × 22 m, safe building weight · Foundation Engineering, chapter 7 · asked 2×