[ML]分类方法评估

一、误差、准确率与估计偏差

首先说明:

  • 定义一个典型的分类函数 f:X → \rightarrow Y
  • X:可以理解为真实世界中的所有样本。当然我们不可能真的获取,比如我们不可能去找来世界上所有西瓜的数据。
  • D:X的概率分布,这里可以理解为在真实世界的情况下
  • S:从X中取出 n 个样本组成的集合
  • h:假设函数,学习后接近真正函数 f
1. 真实误差 True Error

e r r o r D ( h ) = P r x ∈ D [ f ( x ) ≠ h ( x ) ] error_{D}(h) = Pr_{x \in D}[f(x) \neq h(x)] errorD(h)=PrxD[f(x)=h(x)]

真实误差等于假设函数 h 对在 D 上的一个随机样本分类错误的概率。

2. 样本误差 Sample Error

e r r o r S ( h ) = 1 n ∑ x ∈ S δ [ f ( x ) ≠ h ( x ) ] error_{S}(h) = \frac{1}{n} \sum_{x \in S} \delta[f(x) \neq h(x)] errorS(h)=n1xSδ[f(x)=h(x)]

如果 f ( x ) ≠ h ( x ) f(x) \neq h(x) f(x)=h(x)为真,则 δ [ f ( x ) ≠ h ( x ) ] \delta[f(x) \neq h(x)] δ[f(x)=h(x)] 的结果为 1,否则为 0.

说白了,一个n个样本,挨个样本的比较假设函数 h 和真实函数 f 的结果,每有一个俩结果不一样的情况,就总数+1,最后的误差就是 分错的总数 / 样本总数

3. 准确率 Accuracy

a c c u r a c y ( h ) = 1 − e r r o r ( h ) accuracy(h)=1-error(h) accuracy(h)=1error(h)

4.估计误差 Estimation bias

b i a s ≡ E [ e r r o r S ( h ) ] − e r r o r D ( h ) bias \equiv E[error_{S}(h)] - error_{D}(h) biasE[errorS(h)]errorD(h)

E [ e r r o r S ( h ) ] E[error_{S}(h)] E[errorS(h)] 为样本误差 e r r o r S ( h ) error_{S}(h) errorS(h) 的期望值,那为什么不是 b i a s ≡ e r r o r S ( h ) − e r r o r D ( h ) bias \equiv error_{S}(h) - error_{D}(h) biaserrorS(h)errorD(h) 呢?

我个人理解是,由于所用的样本有很大的随机性, e r r o r S ( h ) error_{S}(h) errorS(h)的值是因样本的不同存在变化的,但是这个误差的期望是一个很确定的值。

就比如摇骰子,摇一次,结果为数字2,那实际得到数字1的概率为0,但是得到数字1的期望为确定的 1/6.

二、K折交叉验证 K-fold Cross Validation

将数据集划分为 K 个子集,每个子集都保持数据分布的一致性,在训练时,依次将每一个子集作为测试集,其余子集合并作为训练集。

D:总数据集,被划分为K个子集
L:所用学习算法
T:所用训练数据,为 K-1个子集的并集
h:学习算法L在数据T上的结果,L(T)
δ \delta δ:结果h的误差, e r r o r S ( h ) error_{S}(h) errorS(h)

其误差为: e r r o r L , D ≡ 1 k ∑ i = 1 k δ i error_{L, D} \equiv \frac{1}{k} \sum_{i=1}^k \delta_{i} errorL,Dk1i=1kδi

准确率为: a c c u r a c y L , D = 1 − e r r o r L , D accuracy_{L,D} = 1 - error_{L, D} accuracyL,D=1errorL,D

三、分类性能矩阵

|

1.错误率 Error Rate

即分错的数量除以总数量:

Error rate = | errors | / | instances | = (FN + FP) / (TP + TN + FP + FN)

2.准确率 Accuracy

即 1 减去错误率:

Accuracy = 1 - Error rate = (TP + TN) / (TP + TN + FP + FN)

3.召回率 Recall

Recall = | true positives | / | real positives | = TP / (TP + FN)

ability to avoid false negatives (1 if FN = 0)

4.精确率 Precision

Precision = | true positives | / | predicted positives | = TP / (TP + FP)

ability to avoid false positives (1 if FP = 0)

5.F1-Score

是精确率和召回率的调和平均数,最大为1,最小为0

F 1 − s c o r e = 2 ( P r e c i s i o n ⋅ R e c a l l ) ( P r e c i s i o n + R e c a l l ) F1-score = 2 \frac{(Precision · Recall)}{(Precision + Recall)} F1score=2(Precision+Recall)(PrecisionRecall)

6.混淆矩阵 Confusion Matrix

在这里插入图片描述
混淆矩阵适用于有多个类要分类时,对角线为每个类的准确数量。

7.其他性能度量

Recall, Sensitivity, True Positive Rate
TPR = TP/P = TP/(TP + FN)

Specificity, True Negative Rate
TNR = TN/N = TN/(TN + FP)

False Positive Rate
FPR = FP/N = TP/(TN + FP)

False Negative Rate
FNR = FN/P = FN/(TP + FN)

ROC curve: plot TPR vs FPR varying classification threshold
AUC (Area Under the Curve)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

是土豆大叔啊!

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值