MCC
1. 定义
MCC ——Matthews correlation coefficient , 马修斯相关系数。sklearn.metrics.matthews_corrcoef
The Matthews correlation coefficient is used in machine learning as a measure of the quality of binary and multiclass classifications. It takes into account true and false positives and negatives and is generally regarded as a balanced measure which can be used even if the classes are of very different sizes. The MCC is in essence a correlation coefficient value between -1 and +1. A coefficient of +1 represents a perfect prediction, 0 an average random prediction and -1 an inverse prediction. The statistic is also known as the phi coefficient. [source: Wikipedia]
马修斯相关系数在机器学习中被用来衡量二分类和多分类。它考虑真和假阳性和阴性,通常被认为是一种平衡的测量,即使类别的数目非常不同,也可以使用。其本质是一个介于-1到+1之间的相关系数。
- 1代表完美预测
- 0代表平均随机预测
- -1代表相反的预测
也叫phi 系数。
2. 计算公式
MCC可以直接用混淆矩阵计算 MCC WiKi:
至于TP,FP, TN, FN跟TPR, FPR中计算是一样的
Matthew原本给出的公式:
3. 用法
用法:matthews_corrcoef(y_true, y_pred)
还有个参数 :样本权重sample_weight:array-like of shape (n_samples,), default=None
返回float 常数
from sklearn.metrics import matthews_corrcoef
y_true = [+1, +1, +1, -1]
y_pred = [+1, -1, +1, +1]
matthews_corrcoef(y_true, y_pred)
======================================
-0.3333333333333333
网友评论