Kernel Methods and Prototype Representations
In this chapter, you'll learn about:
- Prototype Representations: Describing a prediction problem using representative examples or class centers.
- Nearest-Neighbor Style Methods: Making predictions from local similarity in the input space.
- Feature Maps and Kernels: Extending linear models by measuring similarity in richer spaces.
- The Kernel Trick: Computing inner products in high-dimensional feature spaces without constructing those features explicitly.
- Tradeoffs: When prototype and kernel methods are powerful, and when they become expensive or fragile.
So far, most models in this section have the form
which means their decision boundaries are linear in the chosen features. That is often a strong baseline, but sometimes the geometry of the problem is more naturally expressed in terms of similarity:
- Which training examples look most like the new input?
- Which class prototype is closest?
- How similar are two inputs after a nonlinear feature transformation?
Prototype methods and kernel methods answer those questions directly.
Prototype-Based Thinking
A prototype is a representative point or reference example used to summarize a region of the input space.
Examples:
- a class mean in nearest-centroid classification
- a stored training example in nearest-neighbor methods
- a learned reference point in radial basis function models
The central idea is that prediction can be based on closeness to prototypes rather than only on a global linear rule.
Nearest Neighbor
The simplest prototype method is nearest neighbor.
Given a training set and a distance function , the 1-nearest-neighbor prediction is:
This method:
- has essentially no explicit training phase
- can represent highly nonlinear decision boundaries
- depends strongly on the metric and feature scaling
k-Nearest Neighbors
Instead of using only one neighbor, k-NN uses the closest examples.
- In classification, it usually predicts by majority vote.
- In regression, it usually predicts by averaging the neighbors' targets.
Increasing usually:
- reduces variance
- increases bias
This makes itself a hyperparameter that should be selected using validation data.
Class Prototypes
Sometimes we do not want to store every training example. A cheaper approximation is to summarize each class with a small number of prototypes.
Nearest Centroid
For a class , define its centroid:
Then predict the class whose centroid is closest: