使用资源管理器在 weka 中进行预测

Prediction in weka using explorer

一旦我训练并生成了一个模型,从我所看到的例子来看,我们正在使用一个测试集,我们必须在其中输入实际值和预测值,有没有一种方法可以让我输入在进行预测时,此实际列为空或根本无法使用它

举个例子,下面是我的训练集

@relation supermarket
@attribute 'department1' { t}
@attribute 'department2' { t}
@attribute 'department3' { t}
@attribute value

并且正在使用像

这样的测试集
 @relation supermarket
@attribute 'department1' { t}
@attribute 'department2' { t}
@attribute 'department3' { t}
@attribute value

并输出

@relation supermarket
@attribute 'department1' { t}
@attribute 'department2' { t}
@attribute 'department3' { t}
@attribute value
@attribute predicted-value
@attribute predicted-margin

我的问题是我可以从测试集中删除值还是将其保留为空

情况 1:你的训练集和测试集都有 class 个标签

培训:

@relation
simple-training
@attribute
feature1 numeric
feature2 numeric
class string{a,b}
@data
1, 2, b
2, 4, a
.......

测试:

@relation
simple-testing
@attribute
feature1 numeric
feature2 numeric
class string{a,b}
@data
7, 12, a
8, 14, a
.......

在这种情况下,无论您使用的是 k-fold cv 还是训练测试设置,Weka 都不会查看您在测试集中的 class 标签。它从训练中获取模型,盲目地将其应用于测试集,然后将其预测与测试集中的实际 class 标签进行比较。

如果您想查看 classifier 的性能评估,这将很有用。

情况 2:您有 class 个训练数据标签,但没有 class 个测试数据标签。

培训:

@relation
    simple-training
    @attribute
    feature1 numeric
    feature2 numeric
    class string{a,b}
    @data
    1, 2, b
    2, 4, a
    .......

测试:

 @relation
    simple-testing
    @attribute
    feature1 numeric
    feature2 numeric
    class string{a,b}
    @data
    7, 12, ?
    8, 14, ?
    .......

这很正常,因为这是我们需要做的——在看不见的未标记数据上应用训练模型来标记它们!在这种情况下,只需在您的测试 class 标签上放置 ? 标记。 运行 Weka 在此设置后,您将获得这些 ? 标记被预测值替换的输出(您不需要创建任何额外的列,因为这会给您带来错误)。

因此,简而言之,您需要在训练和测试数据中具有兼容性。在测试数据中,如果您不知道该值并且想要预测它,则在该列中放置一个 ? 标记。