在weka中测试没有实例标签的单个实例 [英] Test single instance in weka which has no class label

查看:350
本文介绍了在weka中测试没有实例标签的单个实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题已经被问到了,但是我不明白答案,所以我再次发布这个问题,请回答.

This question is being already asked but i didn't understand the answer so I am again posting the question please do reply.

我有一个weka模型,例如:j48我已经为我的数据集训练了该模型,现在我不得不用一个应该返回类标签的实例来测试该模型.怎么做?

I have a weka model eg: j48 I have trained that model for my dataset and now I have to test the model with a single instance in which it should return the class label. How to do it?

我尝试了以下方法:

1)当我将测试实例的a,b,c,class设为?时.正在显示评估分类器的问题.训练和测试不兼容

1)When I am giving my test instance a,b,c,class for class as ?. It is showing problem evaluating classifier .train and test are not compatible

2)当我列出所有班级标签并放入?时像这样的测试实例的类标签:

2)When I list all the class labels and I put the ? for the class label for the test instance like this:

@attribute class {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27}

@data
1,2,............,?

它没有显示任何类似结果

It is not showing any results like this

=== Evaluation on test set ===
=== Summary ===

Total Number of Instances                0     
Ignored Class Unknown Instances                  1     

=== Detailed Accuracy By Class ===

               TP Rate   FP Rate   Precision   Recall  F-Measure  ROC Area  Class
                 0         0          0         0         0         ?        1
                 0         0          0         0         0         ?        2
                 0         0          0         0         0         ?        3
Weighted Avg.  NaN       NaN        NaN       NaN       NaN       NaN    

混淆矩阵为空

该怎么办?

推荐答案

鉴于OP中的不完整信息,这可能是发生了以下情况:

Given the incomplete information from the OP, here is what probably happened:

您使用

  1. Weka GUI选择器
  2. 选择了 Weka Explorer
  3. 预处理标签
  4. 上加载了训练数据
  5. 选择了分类标签
  6. 选择了 J48 分类器
  7. 在测试选项下选择了提供的测试集,并提供了上述测试集
  8. 点击了开始
  1. the Weka GUI Chooser
  2. selected the Weka Explorer
  3. loaded your training data on the Preprocess tab
  4. selected the Classify tab
  5. selected the J48 classifier
  6. selected Supplied test set under test options and supplied your aforementioned test set
  7. clicked on Start

现在您遇到问题了:

"测试集评估"应该已经放弃了,因为您正在评估分类器-或更好的是:训练有素的模型.但是,为了进行评估,您需要将预测的类别与未提供的实际类别进行比较.因此,缺少类标签的实例将被忽略.

"Evaluation on test set" should have given it away, because you're are evaluating the classifier -or better: the trained model. But for evaluation, you need to compare the predicted class with the actual class, which you didn't supply. Hence, the instance with the missing class label will be ignored.

由于没有其他带有类标签的测试实例,因此混淆矩阵为空.根本没有足够的信息来构建一个. (并且要注意:仅一个实例的混淆矩阵是毫无价值的.)

Since you don't have any other test instances WITH class label, the confusion matrix is empty. There simply is not enough information available to build one. (And just as a side note: A confusion matrix for only one instance is kinda worthless.)

您必须转到更多选项... ,点击输出预测旁边的选择,然后选择一种输出格式,例如 PlainText ,您会看到类似这样的内容:

You have to go to More options ..., click on Choose next to Output predictions and select an output format, e.g. PlainText, and you will see something like:

inst#     actual  predicted error prediction
    1        1:?        1:0       0.757 
    2        1:?        1:0       0.824 
    3        1:?        1:0       0.807 
    4        1:?        1:0       0.807 
    5        1:?        1:0       0.79 
    6        1:?        2:1       0.661 

此输出按分类实例在测试文件中出现的顺序列出它们.此示例摘自关于进行预测"的Weka网站,其中包含以下说明.

This output lists the classified instances in the order they occur in the test file. This example was taken from the Weka site about "Making predictions" with the following explanation.

在这种情况下,直接从测试数据集中获取所有类 属性由实际"列标记为?" 忽略,仅声明每个类都属于一个未知类. 预测的"列显示实例1到5是预测的 属于类别1,其值为0,并且实例6预测为 2类,其值为1.错误字段为空;否则为0.如果有预测 是在带有标签的测试集上执行的,每个实例中 预测与标签不匹配将包含"+".这 估计实例1实际上属于类0的概率 在0.757.

In this case, taken directly from a test dataset where all class attributes were marked by "?", the "actual" column, which can be ignored, simply states that each class belongs to an unknown class. The "predicted" column shows that instances 1 through 5 are predicted to be of class 1, whose value is 0, and instance 6 is predicted to be of class 2, whose value is 1. The error field is empty; if predictions were being performed on a labeled test set, each instance where the prediction failed to match the label would contain a "+". The probability that instance 1 actually belongs to class 0 is estimated at 0.757.

这篇关于在weka中测试没有实例标签的单个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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