Nearest centroid classifier
{{Short description|A classification model in machine learning based on centroids}}
In machine learning, a nearest centroid classifier or nearest prototype classifier is a classification model that assigns to observations the label of the class of training samples whose mean (centroid) is closest to the observation. When applied to text classification using word vectors containing tf*idf weights to represent documents, the nearest centroid classifier is known as the Rocchio classifier because of its similarity to the Rocchio algorithm for relevance feedback.{{cite book
| last1 = Manning
| first1 = Christopher
| last2 = Raghavan
| first2 = Prabhakar
| first3 = Hinrich
| last3 = Schütze
| title = Introduction to Information Retrieval
| chapter = Vector space classification
| publisher = Cambridge University Press
| year = 2008
| url = http://nlp.stanford.edu/IR-book/html/htmledition/rocchio-classification-1.html
}}
An extended version of the nearest centroid classifier has found applications in the medical domain, specifically classification of tumors.{{cite journal
| last1 = Tibshirani
| first1 = Robert
| authorlink1 = Robert Tibshirani
| last2 = Hastie
| first2 = Trevor
| authorlink2 = Trevor Hastie
| last3 = Narasimhan
| first3 = Balasubramanian
| last4 = Chu
| first4 = Gilbert
| title = Diagnosis of multiple cancer types by shrunken centroids of gene expression
| journal = Proceedings of the National Academy of Sciences
| volume = 99
| number = 10
| year = 2002
| doi = 10.1073/pnas.082099299
| pages=6567–6572
| pmid=12011421
| pmc=124443
| doi-access = free
| bibcode = 2002PNAS...99.6567T
}}
Algorithm
=Training=
Given labeled training samples with class labels , compute the per-class centroids where is the set of indices of samples belonging to class .
=Prediction=
The class assigned to an observation is .