3

So far, I have read some highly cited metric learning papers. The general idea of such papers is to learn a mapping such that mapped data points with same label lie close to each other and far from samples of other classes. To evaluate such techniques they report the accuracy of the KNN classifier on the generated embedding. So my question is if we have a labelled dataset and we are interested in increasing the accuracy of classification task, why do not we learn a classifier on the original datapoints. I mean instead of finding a new embedding which suites KNN classifier, we can learn a classifier that fits the (not embedded) datapoints. Based on what I have read so far the classification accuracy of such classifiers is much better than metric learning approaches. Is there a study that shows metric learning+KNN performs better than fitting a (good) classifier at least on some datasets?

Sepehr
  • 31
  • 1
  • Do you have an examples of papers or problems where this technique is used? – Ryan Stout Jul 17 '17 at 20:17
  • If you mean metric learning+KNN approaches, then there are a ton of them, "Distance Metric Learning for Large Margin Nearest Neighbor Classification", "Hamming distance metric learning", "Deep metric learning for person re-identification", ... – Sepehr Jul 17 '17 at 20:24
  • 1
    Your question was basically "why do people do [metric learning + KNN]?" In the particular instances where people use that approach, they almost certainly had some reason for doing so. But this question is too vague unless you'd like some specific use case explained. This question as stated might be better suited for something like https://stats.stackexchange.com/ – Ryan Stout Jul 17 '17 at 20:37

2 Answers2

2

Metric learning models CAN BE classifiers. So I will answer the question that why do we need metric learning for classification.

Let me give you an example. When you have a dataset of millions of classes and some classes have only limited examples, let's say less than 5. If you use classifiers such as SVMs or normal CNNs, you will find it impossible to train because those classifiers (discriminative models) will totally ignore the classes of few examples.

But for the metric learning models, it is not a problem since they are based on generative models.

By the way, the large number of classes is a challenge for discriminative models itself.

The real-life challenge inspires us to explore more better models.

Tengerye
  • 1,082
  • 13
  • 31
  • Thanks. I agree with you but if that`s the real application of metric learning techniques then the experimental setup of such papers papers must reflect this scenario. In other words, in the experiments, we should have some class labels for which there is no or very few samples and then we can see the generalisation power the learned mapping. However, in most of the papers I saw that the mapping is applied to some of the popular datasets such as cifar-10 (that has equal number of samples per class label) and then the accuracy of KNN classifier is measured. – Sepehr Mar 16 '18 at 02:59
  • I see your concern. My understanding is when you write a paper to publish, you usually compare your methods with others on some popular **open** datasets which anyone can access. One of the reasons is faculties usually don't access to industrial dataset. The result on open datasets is more convincing since everyone can repeat their experiments. Anyway please don't worry too much, I think if metric-based classifier beats them on balanced dataset it surely it beats them on unbalanced dataset. – Tengerye Mar 16 '18 at 03:13
  • I am looking for an example where metric learning is used for classification, really appreciate if someone provide an example with keras deep learning – user8523104 Feb 14 '21 at 17:17
  • @user8523104 Hi, you can search for 'one-shot learning'. Face verification is an example. – Tengerye Feb 16 '21 at 06:29
  • Thank you yes I could find them :) – user8523104 Feb 17 '21 at 18:11
1

As @Tengerye mentioned, you can use models trained using metric learning for classification. KNN is the simplest approach but you can take the embeddings of your data and train another classifier, be it KNN, SVM, Neural Network, etc. The use of metric learning, in this case, would be to change the original input space to another one which would be easier for a classifier to handle.

Apart from discriminative models being hard to train when data is unbalanced, or even worse, have very few examples per class, they cannot be easily extended for new classes.

Take for example facial recognition, if facial recognition models are trained as classification models, these models would only work for the faces it has seen and wouldn't work for any new face. Of course, you could add images for the faces you wish to add and retrain the model or fine-tune the model if possible, but this is highly impractical. On the other hand, facial recognition models trained using metric learning can generate embeddings for new faces, which can be easily added to the KNN and your system then can identify the new person given his/her image.