---
title: "Rote-learner and K-nearest neighbor"
subject: "Data Mining"
chapter: 3
key: "semester_7/data_mining:rote-learner-knn"
source: https://www.bctengineer.com/q/semester_7/data_mining/rote-learner-knn
site: BCT Engineering
---

# Rote-learner and K-nearest neighbor

Data Mining · Chapter 3: Classification

- Asked in: year not given
- 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/rote-learner-knn
- Whole chapter: https://www.bctengineer.com/md/semester_7/data_mining/chapter-3

## Question

What is rote-learner? Describe K-Nearest Neighbor Classifier with an example. Explain issues for choosing K.

## Short answer

A rote learner memorizes training data and classifies only exact matches. The KNN classifier classifies a record by majority vote of its K nearest training records using Euclidean distance; for K=3, the record (2,2) with distances 1.00, 1.41, 4.24 to three neighbors (two Red, one Blue) is classified Red. K too small overfits noise, too large underfits; choose an odd K by cross-validation, and scale attributes.

## Answer

#### Rote learner
A **rote learner** memorises the entire training data and classifies a test record only if its attributes **exactly match** a training record, using that record's class. It cannot classify a record without an exact match, so it is very restrictive. K-nearest neighbour relaxes this to "similar enough".

#### K-Nearest Neighbour (KNN) classifier
KNN is a lazy, instance-based classifier: it stores the training data and builds no model. A record is classified by its **K closest training records** (the neighbours).

Steps:
1. Choose K and a distance measure (Euclidean: d(x, y) = √Σ(xᵢ − yᵢ)²). Normalise attributes.
2. Compute the distance from the unknown record to all training records.
3. Select the K nearest neighbours.
4. Assign the **majority class** among them (or weighted vote with weight 1/d²).

#### Example
Training: A(1, 1) Red, B(1, 2) Red, C(5, 5) Blue, D(6, 5) Blue, E(5, 6) Blue. New record X = (2, 2), K = 3.

| Point | Class | Distance to X |
| --- | --- | --- |
| B | Red | 1.00 |
| A | Red | 1.41 |
| C | Blue | 4.24 |
| D | Blue | 5.00 |
| E | Blue | 5.00 |

The 3 nearest are B, A, C = Red, Red, Blue. **X is classified as Red.**

#### Issues in choosing K
- **K too small** (e.g. 1): sensitive to noise and outliers; overfitting.
- **K too large**: includes points from other classes; the neighbourhood is no longer local; underfitting. If K = n, the majority class is always predicted.
- Use an **odd K** for two classes to avoid ties. A common rule is K ≈ √n.
- Choose K by **cross-validation** on a validation set.
- Use distance-weighted voting to reduce the effect of K.
- Attributes must be scaled, and irrelevant attributes and high dimension should be removed.

## Check yourself

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

1. When does a rote learner classify a test record?
   A. When it is near any training record
   B. Only when its attributes exactly match a training record
   C. When majority of neighbours agree
   D. Always, using the default class
   Answer: B. Rote learning needs an exact match, which is restrictive. (Key point: Rote learner)

2. In the example with X = (2,2) and K = 3, what is the class and why?
   A. Red, because the 3 nearest (B, A, C) are Red, Red, Blue
   B. Blue, because C, D, E are Blue
   C. Red, because A is the nearest
   D. Blue, because Blue has more training points
   Answer: A. Distances 1.00, 1.41, 4.24 give two Red votes and one Blue. (Key point: KNN worked example)

3. What is the problem with a very small K such as 1?
   A. Underfitting
   B. Always predicts the majority class
   C. Sensitive to noise and outliers (overfitting)
   D. Ties cannot occur
   Answer: C. A tiny K lets a single noisy neighbour decide. (Key point: K too small)

4. What happens if K = n (number of training records)?
   A. Each record is classified by its exact match
   B. The model overfits
   C. Distances are not needed but accuracy is perfect
   D. The majority class is always predicted
   Answer: D. All records vote, so the global majority wins. (Key point: K too large)

## Related in Data Mining

- [K-nearest neighbor on student table](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aknn-student-weights) — Data Mining, chapter 3

## Related in other subjects

- [Issues choosing cloud platform](https://www.bctengineer.com/question.md?key=semester_8%2Finformation_system%3Acloud-platform-issues) — Information System, chapter 8
