The nearest neighbor algorithm (kNN) is one of the simplest classifiers: there is no real training, it just stores the labeled examples. To classify a new example, we compute its distance to everything stored, choose the $k$ nearest examples, then give the most frequent class among them. The best-known distance is the Euclidean $d(\mathbf{a},\mathbf{b})=\sqrt{\sum_i (a_i-b_i)^2}$.
Example with two-dimensional vectors: the new example is $(1,1)$, and the stored ones are $A=(1,2)$ of class one, $B=(2,1)$ of class one, and $C=(5,5)$ of class two. The distances are 1, 1, and $\sqrt{32}\approx5.66$. With $k=3$, two vote for the first class and one for the second, so the result is class one.
A small value of $k$ makes the boundaries jagged and sensitive to noise, and a large one makes them smoother but may ignore small classes. Features must be normalized, otherwise the feature with the larger scale dominates the distance.
In audio, kNN is used with MFCC vectors to compare short clips, and it is good for educational experiments on user data. Its drawbacks: slow inference when there are many examples, and sensitivity to high dimensionality. In the lab it runs inside the browser on clips you record yourself, and its results remain educational only. To speed up the search on larger data, indexing structures are used, but the basic idea remains as explained here.
