I have a dataset of images that has the following distribution:
- Class 0: 73,5%
- Class 1: 7%
- Class 2: 15%
- Class 3: 2,5%
- Class 4: 2%
I think I need to add Class Weights to make up for the low amount of images in class 1, 2, 3 and 4.
I have tried calculating the class weights by dividing class 0 with class 1, class 0 with class 2 and so forth.
I'm assuming that class 0 corresponds to 1, as it doesnt need to be scaled? Not sure if that is correct though.
class_weights = np.array([1, 10.5, 4.9, 29.4, 36.75])
and added them to my fit function:
model.fit(x_train, y_train, batch_size=batch_size, class_weight=class_weights, epochs=epochs, validation_data=(x_test, y_test))
I'm unsure if I have calculated the weights correctly, and if this is even how it is supposed to be done?
Hopefully anyone can help clarifying it.