NEAREST CENTROID CLASSIFIER

The Nearest Centroid Classifier is a simple alternative to k-Nearest Neighbors (k-NN) for similarity-based classification. It is also known as the Mean Difference Classifier.

The key idea of this classifier is to assign a test instance to the class whose centroid (mean point) is closest to the test instance using a distance metric (usually Euclidean distance).


Algorithm : Nearest Centroid Classifier

Inputs: Training dataset T, Distance metric d, Test instance t

Output: Predicted class or category

Steps:

  1. Compute the mean (centroid) of each class.
  2. Compute the Euclidean distance between the test instance and the centroid of each class.
  3. Predict the class with the smallest distance to the test instance.

Given Data :

xyClass
31A
52A
43A
76B
67B
85B

We are given a test instance (6, 5) and asked to classify it using Nearest Centroid Classifier.

Step 3: Prediction

  • Since the distance to class B is smaller, the test instance (6, 5) is closer to class B.

→ Predicted class: B

Leave a Reply

Your email address will not be published. Required fields are marked *