I have set up a neural network which has a single output with a sigmoid activation function, which I understand by default is used as a binary classifier where values over 0.5 should belong to class 1 else class 0. After looking at the results of training, it would be a better balance of precision/recall for my task if I set the classification threshold at a lower number, say 0.25.
Is there a proper way to rescale around this new threshold to give a probability of being in a certain class? So for values close to 0.25, its actually around 50% probability of belonging to class 1.
from keras.models import Sequential
from keras.layers import Dense
model = Sequential()
model.add(Dense(1, activation='sigmoid'))
...layers layers layers
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy',precision,recall,f1])
hist = model.fit(X_train.values,y_train.values, epochs=50, batch_size=64,
verbose=1, validation_data=(X_val.values,y_val.values),
callbacks=callbacks_list, shuffle=True)
model.predict(X_test) # ... want to use 0.25 as the cutoff threshold
# but also want the probability of belonging to class 1