Reputation: 115
I have a simple dataset with 20 features and 8 possible labels. For some of the records, however, there could be more than one correct label. I would like to train this model such that the predicted label is one of the possible labels. What would be a good way to accomplish this?
Example: Consider the following record:
[color: grey; legs:2; wings:2; mass: 120g;....]
Some records are labeled as "Sparrow" and few others are named as "Bird". During testing, I don't care which of these labels are assigned to the record as long as it is one of them.
Upvotes: 4
Views: 152
Reputation: 53766
This certainly depends on the model, but if you're using a neural network with cross-entropy loss, it is entirely possible. In usual case, the label is a one-hot vector [0, ..., 0, 1, 0, ... 0]
. It's probabilistic interpretation is that target class is i
with probability 1.0
(and 0.0
for all other classes).
Nothing stops you from defining the label [0, ..., 0, 0.5, 0, ..., 0, 0.5, 0, ... 0]
: the correct class is i
with probability 0.5
and j
with probability 0.5
. The model thus learns that both of these labels are correct for a given input. After the model is trained, you can even output two or more classes, e.g. all classes which probability is higher than threshold
. Or you can always pick the max probable class, in this case either class can be selected.
Note that this trick (called soft classes) works only with probabilistic models, and not all machine learning algorithms are probabilistic. So the choice the model matters here.
Upvotes: 5