My labels are binary vectors of length 5, e.g., [0, 0, 1, 1, 1].
My label set is very biased, 1-to-50, where the case [0, 0, 0, 0, 0] is very common while all other combinations are not. I'd like to weight the uncommon versions using the class_weight argument in the model.fit() function in Keras. I get an error message which says class_weight must contain all classes in the data.
The classes {0, 1, 2, 3, 4} exist in the data but not in class_weight.
Based on this I suspect Keras expects that I only have classes of the form [1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], etc., i.e., only 1 in each entry in the vector. And that I'm supposed to supply the weights as follows:
weight_classes = {
0: 50.0, # for [1, 0, 0, 0, 0]
1: 1.0, # for [0, 1, 0, 0, 0]
# etc.
}
Is there a way to tell Keras to give weights in this fashion:
weight_classes = {
(0, 0, 0, 0, 0): 1.0,
(0, 0, 1, 1, 1): 50.0,
(0, 0, 0, 0, 1): 50.0,
# etc.
}
Or is there some other way to just say that the all zero case is less important?
I've consider just transform the label set to conform to the one-hot-encoding type of representation. But I'd rather not, because the labels will become very large, and there are interdependence between the labels I think might be better represented by having them encoded as I've done. They are interdependent similar to how words in a sentence are dependent, but where individual predictions are valuable independently.
I have also consider just sticking with sub/supersampling, and skip this whole class weighting.