machine-learning - 在 weka 中测试没有类标签的单个实例

标签 machine-learning classification weka prediction

这个问题已经有人问过,但我不明白答案,所以我再次发布这个问题,请回复。

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

我尝试过以下方法:

1)当我将测试实例 a,b,c,class 作为 ? 时。显示评估分类器时出现问题。train 和 test 不兼容

2)当我列出所有类标签并放置?对于测试实例的类标签,如下所示:

@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,............,?

它没有显示任何这样的结果

=== 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 提供的信息不完整,以下是可能发生的情况:

你使用了

  1. Weka GUI 选择器
  2. 选择了Weka Explorer
  3. 已在预处理选项卡上加载您的训练数据
  4. 选择了分类标签
  5. 选择了J48分类器
  6. 在测试选项下选择提供的测试集并提供上述测试集
  7. 点击开始

现在给你解决问题:

对测试集的评估”应该已经泄露了它,因为您正在评估分类器 - 或者更好:经过训练的模型。但为了进行评估,您需要将预测类别与您未提供的实际类别进行比较。因此,缺少类标签的实例将被忽略。

由于您没有任何其他带有类标签的测试实例,因此混淆矩阵为空。根本没有足够的信息来构建一个。 (顺便说一句:仅一个实例的混淆矩阵有点毫无值(value)。)

查看实际预测

您必须转到更多选项...,点击输出预测旁边的选择,然后选择输出格式,例如纯文本,您将看到类似以下内容:

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 

此输出按照测试文件中出现的顺序列出分类实例。这个例子取自the Weka site about "Making predictions"并附有以下解释。

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.

关于machine-learning - 在 weka 中测试没有类标签的单个实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18216266/

相关文章:

machine-learning - Vowpal Wabbit 是否会在多个在线 channel 中对数据进行混洗?

python - Keras 和 Python 3.6 : Error when checking input for Sequential model

python - Tensorflow 将预测值转换为二进制

scikit-learn - scikit-learn (python) 中的平衡随机森林

java - 使用 Weka 每周​​预测明年的温度值

python - ExtraTreesClassifier 的特征重要性返回全零

machine-learning - 哪种方法可以检测文档中手写签名的存在?

python-3.x - 回归与分类的特征选择

machine-learning - 如何将 WEKA 机器学习用于贝叶斯神经网络和 J48 决策树

java - jdbc 不在类路径错误