Why must Neighborhood Components Analysis be fitted inside training folds rather than treated like a fixed distance…
Classic MLLevel: IntermediateSupervised distance learning
Why must Neighborhood Components Analysis be fitted inside training folds rather than treated like a fixed distance metric?
Hints
- The metric itself is learned from y.
- A preprocessing label does not make a step unsupervised.
Answer
NCA learns a feature transformation using class labels to improve neighborhood classification. Fitting it globally exposes validation labels to the distance representation.
Source and licence: scikit-learn 1.7.2 — neighbors · BSD-3-Clause · answer: Quantoros editorial