博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
吴恩达机器学习——数值评价指标
阅读量:3961 次
发布时间:2019-05-24

本文共 3498 字,大约阅读时间需要 11 分钟。

Numerical Evaluation

用数值评价指标来估计算法的执行结果 可以看出学习算法的效果。

在自然语言处理中,可用stemming software(词干提取软件)实现;在搜索引擎中搜Porter Stemmer这种软件进行词干提取。但它们都只处理单词的前几个字母。可以使用交叉验证(not error analysis)在使用词干提取和不使用词干提取条件下分别看看其结果。

Need numerical evaluation(e.g.,cross validation error) of algorithm’s performance with and without stemming.

Without stemming:5% error
With stemming:3% error
   ⟹    \implies using stemming
对于特定的问题,采用单一规则的数值评价指标——the cross validation error.
:要在交叉验证集上做。
other examples:
是否区分大小写,e.g.
Distinguish upper vs. lower case (Mom/mom):3.2%
   ⟹    \implies 不区分

1.形成一个简单算法

2.查看错误,通过误差分析看它出现了什么失误,以此决定之后的优化方法
3.有了算法和数值评价指标后,有助于实验新的想法并验证该想法,决定自己该放弃些什么

the reversed example

For skewed class,需采用其它 Evaluation metric

Case:Cancer classification
   Model: h θ ( x ) { y = 1 if  c a n c e r y = 0 otherwise h_\theta(x)\begin{dcases} y = 1 &\text{if } cancer \\ y = 0 &\text{otherwise} \end{dcases} hθ(x){
y=1y=0if cancerotherwise
   Evaluation metric:分类误差/分类精确度
测试集只有1%的误差,而0.50%的病人have cancer。

function y = predictCancer(x)	y = 0;	%ignore x!return

利用上面非机器学习的算法,误差只有0.50%

⟹ \Longrightarrow 显然误差降低了,but 并未真正提升分类模型的质量

Precision/Recall

在上述例子中, y = 1 y = 1 y=1 in presence of rare class that we want to detect.

Predicted
class
Actual class
1 0
1 True Positive(真阳性) False Negative(假阴性)
0 False Positive(假阳性) True Negative(真阴性)
Precision

(Of all patients where we predicted y = 1 y = 1 y=1, what fraction actually has cancer?)

T r u e p o s i t i v e # p r e d i c t e d p o s i t i v e = T P T P + F P \frac{True\enspace positive}{\#predicted\enspace positive}=\frac{TP}{TP+FP} #predictedpositiveTruepositive=TP+FPTP

即:第一格 比上 第一行.

Recall

(Of all patients that actually have cancer, what fraction did we correctly detect as having cancer?)

T r u e p o s i t i v e # a c t u a l p o s i t i v e = T P T P + F N \frac{True\enspace positive}{\#actual\enspace positive}=\frac{TP}{TP+FN} #actualpositiveTruepositive=TP+FNTP

即:第一格 比上 第一列.

function y = predictCancer(x)	y = 0;	%ignore x!return

若采用上述算法, P r e c i s i o n = 0 , R e c a l l = 0 Precision = 0, Recall = 0 Precision=0,Recall=0.

结论:对偏斜类中的rare class,采用 Precision/Recall 作为评估度量值。

Trading off precision & recall

对于Logistic regression: 0 ≤ h θ ( x ) ≤ 1 0\le h_\theta(x)\le1 0hθ(x)1

Predict 1 if h θ ( x ) ≥ h_\theta(x)\ge hθ(x) threshold
Predict 0 if h θ ( x ) < h_\theta(x) < hθ(x)< threshold
Suppose we want to predict y = 0 y=0 y=0(cancer) only if very confident.(“宁可放过一百,不可错杀一个”)
⟶ \longrightarrow threshold = 0.7,0.9
⟶ \longrightarrow Higher precision, lower recall.
Suppose we want to avoid missing too many cases of cancer(avoid false negatives).(“宁可错杀一百,不可放过一个”)
⟶ \longrightarrow threshold = 0.3,0.1
⟶ \longrightarrow Higher recall, lower precision.

Precision-Recall 可能的曲线

在这里插入图片描述

How to compare precision/recall numbers?

F 1    S c o r e : 2 P R P + R F_1\; Score : 2 \frac{ PR }{P+R} F1Score:2P+RPR

Precision( P ) Recall( R ) Average F 1    S c o r e F_1\; Score F1Score
Algorithm 1 0.5 0.4 0.45 0.444
Algorithm 2 0.7 0.1 0.4 0.175
Algorithm 3 0.02 1.0 0.51 0.392

P = 0 o r R = 0 ⟹ F 1    S c o r e = 0 P=0\enspace or\enspace R=0\Longrightarrow F_1\; Score = 0 P=0orR=0F1Score=0

P = 1 a n d R = 1 ⟹ F 1    S c o r e = 1 P=1\enspace and\enspace R=1\Longrightarrow F_1\; Score = 1 P=1andR=1F1Score=1;
e l s e ⟹ F 1    S c o r e else\Longrightarrow F_1\; Score elseF1Score介于 0 − 1 0-1 01之间

对于Algorithm 3,将Predict均判为 y = 1 y=1 y=1,此时R为1,P极小,显然该算法不可用。若将Average作为数值指标,Algorithm 3的值反而比1和2大。

⟹ \Longrightarrow Average此时不可作为评估度量值。


  1. 是否将它们看作同一个单词,是否将它们看作相同的特征

转载地址:http://nymzi.baihongyu.com/

你可能感兴趣的文章
HTTP状态码
查看>>
go语言
查看>>
mysql mariaDB 以及存储引擎
查看>>
游戏行业了解介绍
查看>>
linux at 命令使用
查看>>
Go在windows下执行命令行指令
查看>>
inotify
查看>>
inode
查看>>
Shell: sh,bash,csh,tcsh等shell的区别
查看>>
golang ubuntu 配置 笔记
查看>>
vim 常用命令
查看>>
golang 开源项目
查看>>
ubntu 开发服务进程
查看>>
linux 常用命令以及技巧
查看>>
记录1年免费亚马逊AWS云服务器申请方法过程及使用技巧
查看>>
golang文章
查看>>
一些特殊的符号
查看>>
shell脚本的exit问题(退出脚本还是退出终端)
查看>>
linux export命令参数及用法详解--linux设置环境变量命令
查看>>
Shell单引号,双引号,反引号,反斜杠
查看>>