How does Large Margin Nearest Neighbor learn a transformation for KNN?
Role: Machine Learning Engineer
Category: Machine Learning
Difficulty: hard
Interview Round: Other
How does Large Margin Nearest Neighbor learn a transformation for KNN?
Describe what the method learns, the objective it minimizes and how that objective is optimized.
```hint Think in triplets
Picture a point, one of its same-class neighbors, and a nearby point from another class. What should the learned distance do to each pair?
```
```hint Look at the distance as a function of the metric
Write the learned distance in terms of the matrix that defines it. How does it depend on that matrix, and what does that imply for the shape of the loss?
```
### What a Strong Answer Covers
- What is learned: a linear map or a positive semidefinite matrix, and the distance it defines
- How target neighbors and impostors are defined
- The two loss terms, the margin, and how they are weighted
- Why the problem is convex in the metric and how it is solved at scale
- How LMNN differs from other metric learning methods such as NCA
### Follow-up Questions
- Why are target neighbors fixed before training, and what happens if the Euclidean neighbors are poor?
- How would you use LMNN to reduce dimensionality, and what do you give up?
- How does training cost scale with the number of points, features and k, and what keeps it tractable?
- When would a learned global metric still fail to help KNN?
Overview: Asks how Large Margin Nearest Neighbor learns a linear transformation, or Mahalanobis metric, that improves k-nearest neighbor classification. Tests knowledge of target neighbors, impostors, the pull and push loss with its margin, and why the problem is convex in the metric.