在tf.contrib.learn.DNNClassifier中使用自定义阈值吗? [英] Using a custom threshold value with tf.contrib.learn.DNNClassifier?

查看:97
本文介绍了在tf.contrib.learn.DNNClassifier中使用自定义阈值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理二进制分类问题,并且正在TensorFlow中使用tf.contrib.learn.DNNClassifier类.仅对2个类别调用此估计器时,它将阈值0.5用作2个类别之间的临界值.我想知道是否可以使用自定义阈值,因为这可能会提高模型的准确性.

I'm working on a binary classification problem and I'm using the tf.contrib.learn.DNNClassifier class within TensorFlow. When invoking this estimator for only 2 classes, it uses a threshold value of 0.5 as the cutoff between the 2 classes. I'd like to know if there's a way to use a custom threshold value since this might improve the model's accuracy.

我已经在网上搜索了很多东西,显然没有办法做到这一点.

I've searched all around the web and apparently there isn't a way to do this.

任何帮助将不胜感激,谢谢.

Any help will be greatly appreciated, thank you.

推荐答案

tf.contrib.learn.DNNClassifier类具有称为predict_proba的方法,该方法返回给定输入的每个类的概率.然后,您可以使用tf.round(prob+thres)之类的东西通过自定义参数thres进行二进制阈值化.

The tf.contrib.learn.DNNClassifier class has a method called predict_proba which returns the probabilities belonging to each class for the given inputs. Then you can use something like, tf.round(prob+thres) for binary thresholding with the custom parameter thres.

这篇关于在tf.contrib.learn.DNNClassifier中使用自定义阈值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆