[WEKA] 2 evaluation

How do I evaluate a classifier’s performance?

Extending Weka with “packages”

进入The Package Manager

Be a classifier! 分类器

 Load segmentchallenge.arff; look at dataset //图像识别数据集
 Select UserClassifier (tree classifier)
 Use the test set segmenttest.arff
 Examine data visualizer and tree visualizer //运行分类器,可以看到窗口有两个面板:树形可视化和数据可视化
 Plot regioncentroidrow vs intensitymean //选择合适的X轴Y轴
 Rectangle, Polygon and Polyline selection tools //user自己分类
 … several selections … //选择后submit,选择的区域会消失
 Rightclick in Tree visualizer and Accept the tree

userclassifier

右键accept

Over to you: how well can you do?
一开始整整齐齐的,但是跑出来是00000(X class;Y hedge means),后来随意分类了一下,跑了78%,但是没有评论里的同学跑得高。
基本上,我们尝试了实例空间的不同区域,找纯度最高的区域来建纯度最高的分支。这是由底至上的覆盖策略。我们覆盖这片区域,这片区域和这片区域。这不是 J48 的工作方法。
当 J48 创建树时,它用整个数据集来划分。在最顶端,它将数据集一分为二时,不是为了更好的分类,而是为了它可以使用由顶至下的方法将每次剩下的一半数据建成最优化的树形。它所创建的树比我刚刚用用户分类器所建的要好。

Training and testing 训练和测试

Use J48 to analyze the segment dataset 用 J48 分析 segmentchallenge数据集

 Open file segment-challenge.arff
 Choose J48 decision tree learner (trees>J48
)
 Supplied test set segment-test.arff //测试集
 Run it: 96% accuracy
 Evaluate on training set: 99% accuracy //Overfitting
 Evaluate on percentage split: 95% accuracy
 Do it again: get exactly the same result! //在运行前 Weka 会初始化随机数生成器,以保证你能得到重复的结果

training and test sets sampled independently from an infinite population。训练和测试数据都是分别取自无限总体的独立样本。两组数据都是不同的独立样本,不可以是同样的数据。
这周的question主要在考用split划分training set和test set。这个percentage split的百分数指的是训练集,评估是用的是剩下的那部分测试集。

Repeated training and testing 重复训练和测试

  1. 种子
    setting the random-number seed:[More options] Repeat with seed
    划分的比例是不变的,种子改变的是什么?样本状态吗?
    这里的random指的是randomly splitting
    设置种子
  2. 准确率的mean和Variance
    Variance是除以(n-1)的。
    Question:
    weka中是四舍五入的。Weka doesn’t truncate, it rounds to the nearest integer.

Baseline accuracy 基线精确度

  1. Consider whether differences are likely to be significant 判断精确度的提高是否显著
    当精确度有微小的提高时,你需要考虑下这些提高是否是显著的。 1%的区别,就很可能并不显著。
  2. Always try a simple baseline 基线精确度
    e.g. rules > ZeroR
    一般来说,简单的是最好的。在尝试复杂的分类器前,先试一试简单的。可以总是先尝试下基线分类器ZeroR。
  3. Look at the dataset, Don’t blindly apply Weka:
    try to understand what’s going on!
    (可能对于这个数据集,属性并不作为分类的依据。

Cross-validation 交叉验证

之前我们用过的评估方法有:

1. repeated holdout 重复预留法

hold out 10% for testing, repeat 10 times
经用不同的随机种子来运行预留法,减少预测误差。

2. Cross-validation 交叉验证

10-fold cross-validation 10 层交叉验证

  1. Divide dataset into 10 parts (folds)
  2. Hold out each part in turn
  3. Average the results
  4. Each data point used once for testing, 9 times for training

3. Stratified cross-validation 分层交叉验证

Ensure that each fold has the right proportion of each class value
总结:

  1. Cross-validation better than repeated holdout
    分层交叉验证更加精确,Weka 的默认值是分层交叉验证。
    运行十次重复预留的结果并不如交叉验证好。
  2. With 10-fold cross-validation, Weka invokes the learning algorithm 11 times
    使用 10 层交叉验证,Weka 需要进行 11 次算法运算,前 10 次用每一份数据,最后一次用整个数据集。
  3. 选择评估方式的最实用的原则
    -Lots of data? – use percentage split 如果你有足够多的数据,你可以用百分比分割数据集并只评估一次。
    -Else stratified 10-fold cross-validation 如果你没有那么多数据,你需要使用 10 层交叉验证。

一开始以为用split重复预留是为了得到不同的model,找到更好的model,原来不是为了建模而是为了评估吗?有点奇怪这一点。
还有在第十一次用整个数据集,那评估结果是前十次的均值还是最后一次,前十次有什么意义?
最后一次用了全部的数据,就是全部的数据都是训练集,那就没办法做测试,所以最后一次是为了得到model?
又看了一下,以上有一个误解就是评价model,但这里是在评价这个分类器J48.

Cross-validation results

用zeroR找基线
交叉验证优越于重复预留法,均值相同,但是交叉验证的误差要小得多。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值