I have a multi-label classification problem that I am working on where some of the labels are imbalanced and I want to set the threshold differently for each label. I was doing the following before but this uses the same threshold for all the labels.
results_pred = model.predict(x_test_np, batch_size=1)
results_pred[results_pred >= 0.2] = 1
results_pred[results_pred < 0.2] = 0
Also during the training how to set the threshold differently for each label for the precision and recall metrics. I do this now:
model.compile(loss='binary_crossentropy',optimizer=opt,metrics=['accuracy',tf.keras.metrics.Precision(thresholds=0.2),tf.keras.metrics.Recall(thresholds=0.2)])