-1

I was wondering if FastText is able to deal with multi-labelled data? Could someone share a simple example along with a confusion matrix (true vs predicted labels)? I have already taken a look at FastText documentation page.

Thank you in advance

2 Answers2

1

This section describes multi label classification: https://github.com/facebookresearch/fastText/blob/main/docs/supervised-tutorial.md#multi-label-classification

A convenient way to handle multiple labels is to use independent binary classifiers for each label. This can be done with -loss one-vs-all or -loss ova.

Preparing training data

That has been described at the end of the section Installing fastText

Each line of the text file contains a list of labels, followed by the corresponding document. All the labels start by the __label __ prefix, which is how fastText recognize what is a label or what is a word.

Kaushik Acharya
  • 1,520
  • 2
  • 16
  • 25
0

The docs, & the format for supplying labeled text, only seem to mention a single label per text.

You could try repeating the same text more than once in your training data, each time with one of the appropriate labels. (You might want to re-shuffle the training data so that such repeated texts don't appear directly alongside each other.)

gojomo
  • 52,260
  • 14
  • 86
  • 115
  • 1
    Thanks for your idea! By documentation, it says that using parameter loss = 'ova' (one-vs-all) should be used while performing multi-label classification. Does it do the same thing as you described? – anonymousPenguin Mar 13 '22 at 15:43
  • No, because what I described is preprocessing your existing multi-labeled training data to fit Fastttext's one-label-per-example input-format. AFAICT, that `ova` option only changes the *internal model* & *method-of-calculating-probabilities* – allowing the predictions to predict a series of labels with total probabilities exceeding the usual `1.0`. It may be complementary to my input-mangling suggestion; I'd try your system both with & without `ova` to see which gives more useful prediction-probabilities for your specific data/task. – gojomo Mar 14 '22 at 18:01