The training points are red, red, blue, blue and blue. Using Euclidean distance, classify the query with , and . What does this tell you about the choice of ?
Supervised learning, k-nearest neighbours
Level L2 Elementary. Length Short. Nature Mat Mathematical.
What's being asked
Whether you can run k-NN by hand: compute distances, sort, then take a majority vote.
Key idea
Compute for each point, sort, and vote among the nearest. The answer can change with .
Steps
- Distances from : , , , , .
- Sort: blue, red, red, blue, blue.
- and : for only is used, so blue; for the nearest are (1 blue and 2 red), so red.
- : all points, 3 blue and 2 red, so blue (the majority of the whole set).
- The label flips between , and because the query sits between the clusters. So matters, and should be chosen by cross-validation. Note also that always returns the global majority.
Common mistakes
- Mixing up squared and ordinary distances. Squared distances give the same ordering, so the vote is the same, but do not mix the two in one table.
- Counting the query point as its own neighbour. It is not in the training set.
- Not checking for ties in distance before cutting at .
How long your answer should be
A small table and 5 lines.
Read this
Previous in Supervised learning: A 3-class classifier may also reject (refuse to decide). A wrong decision costs 1, a correct decision costs 0, and rejecting costs . For the posteriors and , what should the classifier do? What is the general rule in terms of ?
Next in Supervised learning: A multinomial naive Bayes spam filter uses the vocabulary . Training: spam documents "win win cash" and "cash cash"; ham documents "meeting win" and "meeting meeting cash". Using Laplace (add-one) smoothing, classify the new document "win meeting meeting". Why is the smoothing needed?