def micro_recall(self, y_true, y_pred): return K.sum(self.true_positive(y_true, y_pred)) / (K.sum(y_true) + K.epsilon())
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())
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())
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())
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())
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
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