Esempio n. 1
0
 def micro_recall(self, y_true, y_pred):
     return K.sum(self.true_positive(y_true, y_pred)) / (K.sum(y_true) + K.epsilon())
Esempio n. 2
0
 def macro_recall(self, y_true, y_pred):
     class_count = y_pred.shape[-1]
     return K.sum([self.class_recall(i, y_true, y_pred) for i in range(class_count)]) \
         / K.cast(class_count, K.floatx())
Esempio n. 3
0
 def micro_precision(self, y_true, y_pred):
     y_pred = self.normalize_y_pred(y_pred)
     return K.sum(self.true_positive(y_true, y_pred)) / (K.sum(y_pred) + K.epsilon())
Esempio n. 4
0
 def class_recall(self, class_label, y_true, y_pred):
     return K.sum(self.class_true_positive(class_label, y_true, y_pred)) / (K.sum(y_true[:, class_label]) + K.epsilon())
Esempio n. 5
0
 def class_precision(self, class_label, y_true, y_pred):
     y_pred = self.normalize_y_pred(y_pred)
     return K.sum(self.class_true_positive(class_label, y_true, y_pred)) / (K.sum(y_pred[:, class_label]) + K.epsilon())
Esempio n. 6
0
def precision_m(y_true, y_pred):
    true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
    predicted_positives = K.sum(K.round(K.clip(y_pred, 0, 1)))
    precision = true_positives / (predicted_positives + K.epsilon())
    return precision
Esempio n. 7
0
def recall_m(y_true, y_pred):
    true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
    possible_positives = K.sum(K.round(K.clip(y_true, 0, 1)))
    recall = true_positives / (possible_positives + K.epsilon())
    return recall