0
$\begingroup$

I am building a text classifier, the labels in my training data are not just short names like "Dog" or "Cat", they are more of lengthy sentences that range from 2 words to around 20 words.

Does the length of the label/class name affect the performance of the classifier? in other words, should I try to shorten the names?

$\endgroup$

1 Answer 1

0
$\begingroup$

Definitely not. Because the classifier won't bother with how you name your classes, but how are they encoded.

Basically, if you can have only one class per input value, you can use one-hot encoding, that is for each input value you will have a target converted from the string "Cat", for example, to [0, 1] given that you have two classes, where the other one is "Dog", which will become [1, 0].

Of course, this is by no means limited to 2 classes. You could have any N classes, be it in the order of tens or even hundreds, but the idea still applies, one 1 and N-1 0s.

You could also convert your classes to integers, some algorithms can work with that too.

Now, if you can have multiple classes per input value, you could for example encode them as 1 for each class position in the target vector and 0s for the rest.

Let's say you have the following classes: Has fur, Is carnivorous, Feeds alone. Then a lion would have the target value encoded as [1, 1, 0], and a sheep will correspond to [1, 0, 0].

Hope this answers your question.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.