如何计算张量流中的矩阵相关系数 [英] How do I calculate the matthews correlation coefficient in tensorflow

查看:155
本文介绍了如何计算张量流中的矩阵相关系数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我用tensorflow keras制作了一个模型,看起来工作正常.但是,我的主管说,计算马修斯相关系数以及已经计算出的准确度和损失将非常有用.

So I made a model with tensorflow keras and it seems to work ok. However, my supervisor said it would be useful to calculate the Matthews correlation coefficient, as well as the accuracy and loss it already calculates.

我的模型与此处的教程中的代码非常相似( https://www. tensorflow.org/tutorials/keras/basic_classification ),但数据集要小得多.

my model is very similar to the code in the tutorial here (https://www.tensorflow.org/tutorials/keras/basic_classification) except with a much smaller dataset.

是否有预构建的函数,或者我必须获取每个测试的预测并手动进行计算?

is there a prebuilt function or would I have to get the prediction for each test and calculate it by hand?

推荐答案

用于计算矩阵相关系数的预构建函数

Prebuilt function to calculate matthews correlation coefficient

sklearn.metrics.matthews_corrcoef(y_true, y_pred, sample_weight=None )

示例:

> from sklearn.metrics import matthews_corrcoef
> y_true = [+1, +1, +1, -1]
> y_pred = [+1, -1, +1, +1]
> matthews_corrcoef(y_true, y_pred) 

请参考 https://scikit-learn.org/stable/modules/model_evaluation.html#matthews-corrcoef

希望这会有所帮助.

这篇关于如何计算张量流中的矩阵相关系数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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