# accuracy, fmeasure, precision,recall
def mcor(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 precision(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(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 def f1(y_true, y_pred):
def recall(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 def precision(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 precision = precision(y_true, y_pred)
recall = recall(y_true, y_pred)
return 2*((precision*recall)/(precision+recall+K.epsilon()))

keras recall的更多相关文章

  1. 【tf.keras】实现 F1 score、precision、recall 等 metric

    tf.keras.metric 里面竟然没有实现 F1 score.recall.precision 等指标,一开始觉得真不可思议.但这是有原因的,这些指标在 batch-wise 上计算都没有意义, ...

  2. [深度应用]·DC竞赛轴承故障检测开源Baseline(基于Keras 1D卷积 val_acc:0.99780)

    [深度应用]·DC竞赛轴承故障检测开源Baseline(基于Keras1D卷积 val_acc:0.99780) 个人网站--> http://www.yansongsong.cn/ Githu ...

  3. 基于keras的fasttext短文本分类

    ### train_model.py ### #!/usr/bin/env python # coding=utf-8 import codecs import simplejson as json ...

  4. How to compute f1 score for each epoch in Keras

    https://medium.com/@thongonary/how-to-compute-f1-score-for-each-epoch-in-keras-a1acd17715a2 https:// ...

  5. keras如何求分类问题中的准确率和召回率

    https://www.zhihu.com/question/53294625 由于要用keras做一个多分类的问题,评价标准采用precision,recall,和f1_score:但是keras中 ...

  6. Keras 入门

    “sample”“batch”“epoch” Sample:样本,比如:一张图像是一个样本,一段音频也是一个样本. Batch:批,含有N个样本的集合.每一个batch的样本都是独立的并行处理.在训练 ...

  7. Keras实现CIFAR-10分类

      仅仅为了学习Keras的使用,使用一个四层的全连接网络对MNIST数据集进行分类,网络模型各层结点数为:3072: : 1024 : 512:10:   使用50000张图片进行训练,10000张 ...

  8. Keras实现MNIST分类

      仅仅为了学习Keras的使用,使用一个四层的全连接网络对MNIST数据集进行分类,网络模型各层结点数为:784: 256: 128 : 10:   使用整体数据集的75%作为训练集,25%作为测试 ...

  9. 【tf.keras】使用手册

    目录 0. 简介 1. 安装 1.1 安装 CUDA 和 cuDNN 2. 数据集 2.1 使用 tensorflow_datasets 导入公共数据集 2.2 数据集过大导致内存溢出 2.3 加载 ...

随机推荐

  1. 七、设备驱动中的阻塞与非阻塞 IO(二)

    7.2 轮询 7.2.1 介绍 在用户程序中的 select() 和 poll() 函数最终会使设备驱动中的 poll() 函数被执行. 设备驱动程序中的轮询函数原型: /** 用于询问设备是否可以非 ...

  2. IDL_MCTK(MODIS Conversion Toolkit)

    1.CONVERT_MODIS_DATA CONVERT_MODIS_DATA [,IN_FILE= | | }] [,GEOLOC_FILE= | | }] [,CALIB_METHOD={ | | ...

  3. 2018 ACM-ICPC 区域赛(青岛站)题解整理

    题目链接 C - Flippy Sequence(组合数学+分类讨论) 两区间异或一下,分段考虑,如果全为0则任选两相同区间,答案为$C_{n+1}^{2}=\frac{n(n+1)}{2}$,只有一 ...

  4. css不常见属性之pointer-events

    MDN 上介绍为 CSS 属性指定在什么情况下 (如果有) 某个特定的图形元素可以成为鼠标事件的 target.pointer-events 属性值有: /* Keyword values */ po ...

  5. 关于mysql备份与恢复的操作

    逻辑备份:将数据库的数据以逻辑的SQL语句的方式导出 mysqldump备份数据库 备份数据并带创建数据库 (含数据) mysqldump -uroot -p'123456' -B dbname &g ...

  6. Python机器学习常用库记录

    1.argparse http://www.jianshu.com/p/fef2d215b91d 命令行解释工具 2.tflearn http://tflearn.org/doc_index/ ten ...

  7. Vue组件创建和组件传值

    Vue创建组件的方式 使用Vue.Extend()和Vue.component全局注册组件 首先我们定义一个组件并接收 var com1 =Vue.extend({ template:"&l ...

  8. 2019hdu多校 Keen On Everything But Triangle

    Problem Description N sticks are arranged in a row, and their lengths are a1,a2,...,aN. There are Q ...

  9. luoguP1514 引水入城 x

    P1514 引水入城 题目描述 在一个遥远的国度,一侧是风景秀美的湖泊,另一侧则是漫无边际的沙漠.该国的行政区划十分特殊,刚好构成一个N 行M 列的矩形,如上图所示,其中每个格子都代表一座城市,每座城 ...

  10. python实现RGB转换HSV

    def rgb2hsv(r, g, b):     r, g, b = r/255.0, g/255.0, b/255.0     mx = max(r, g, b)     mn = min(r,  ...