I want to build MSFE loss function.
This function proposed this paper. https://ieeexplore.ieee.org/document/7727770
And here's the concept of it. Please check table, MSE, MFE, and MSFE.
My question is that,
- Is it possible to divide True Positive, False Postivie, False Negative, True Positive before running model? How could we know y_pred's result even before running prediction model?
In this SO, it is impossible to use this code. Then I think it is impossible. Could you tell me is there any other way?
TN = np.logical_and(K.eval(y_true) == 0, K.eval(y_pred) == 0)
- How could I build a custom function for cost-sensitive learning?
Custom loss function in Keras to penalize false negatives Keras Custom loss function to pass arguments other than y_true and y_pred https://datascience.stackexchange.com/questions/28440/custom-conditional-loss-function-in-keras
- This is what I made. How could I improve this function?
def custom_loss_wrapper(p):
def custom_loss(y_true, y_pred):
y_true = tf.cast(y_true, tf.float32)
y_pred = tf.cast(y_pred, tf.float32)
fp = K.sum(y_pred * (1 - y_true))
fn = K.sum((1 - y_pred) * y_true)
cost = tf.cast(fn * p + fp, tf.float32)
return cost
return custom_loss