def matthews_correlation(y_true, y_pred):
 y_pred_pos = K.round(K.clip(y_pred, 0, 1))
 y_pred_neg = (1 - y_pred_pos)
 y_pos = K.round(K.clip(y_true, 0, 1))
 y_neg = (1 - y_pos)
 tp = K.sum((y_pos * y_pred_pos))
 tn = K.sum((y_neg * y_pred_neg))
 fp = K.sum((y_neg * y_pred_pos))
 fn = K.sum((y_pos * y_pred_neg))
 numerator = ((tp * tn) - (fp * fn))
 denominator = K.sqrt(((((tp + fp) * (tp + fn)) * (tn + fp)) * (tn + fn)))
 return (numerator / (denominator + K.epsilon()))

def matthews_correlation ( y_true , y_pred ) : y_pred_pos = K . round ( K . clip ( y_pred , 0 , 1 ) ) y_pred_neg = ( 1 - y_pred_pos ) y_pos = K . round ( K . clip ( y_true , 0 , 1 ) ) y_neg = ( 1 - y_pos ) tp = K . sum ( ( y_pos * y_pred_pos ) ) tn = K . sum ( ( y_neg * y_pred_neg ) ) fp = K . sum ( ( y_neg * y_pred_pos ) ) fn = K . sum ( ( y_pos * y_pred_neg ) ) numerator = ( ( tp * tn ) - ( fp * fn ) ) denominator = K . sqrt ( ( ( ( ( tp + fp ) * ( tp + fn ) ) * ( tn + fp ) ) * ( tn + fn ) ) ) return ( numerator / ( denominator + K . epsilon ( ) ) )
matthews correlation metric .