Reputation: 10481
I have data which is labelled with 5 categories.
Each category represent the same event of different intensity in physical world.
The importance of that fact is that category 5 is basically must stronger version of the same event as category 1 (eg earthquake).
Can someone please offer an idea how to make this knowledge available to the model (TF/Keras) ?
Upvotes: 0
Views: 51
Reputation: 857
One-Hot Encoding is common for multi-class classification problems. In your case, a category 3 event label would be encoded as [0, 0, 1, 0, 0]. You would create a model with a dense output layer with softmax activations, then to get a prediction you would take the argmax of the output layer to get the category.
If you are asking how you can embody the fact that all of your categories are variations of the same class, you may want to look into Embedding Layers. Basically an embedding layer converts a categorical (sparse) vector into a dense vector, and allows that conversion to be a learnable parameter of the model. It allows the model to group similar classes together in vector space. It's commonly used in language modelling for grouping similar words together. For example, Woman, Lady, Queen would be closer together in the embedding vector than Man, Lord, King. In your case, class 1,2,3 may be closer together than 4,5 and an embedding layer would allow your model to learn that.
Upvotes: 3