在命令行中导出Weka预测结果

3

我能在GUI中成功地导出分类器错误,但无法在命令行中执行此操作。有没有办法在命令行上实现这个功能?

我正在使用Weka 3.6.x。您可以右键单击模型,选择“可视化分类器错误”并从那里保存数据(包括预测)。我想在命令行上做同样的事情。

我不太关心文件格式(arff或csv都可以),但重要的是我要获得测试数据的每个实例的错误值。

我之前在 [这个问题] 中询问过。(Weka Predictions to CSV

1个回答

4
您可以通过在每个分类器中使用以下选项,在命令行中获取预测、概率等信息:
-classifications "weka.classifiers.evaluation.output.prediction.AbstractOutput + options"
        Uses the specified class for generating the classification output.
        E.g.: weka.classifiers.evaluation.output.prediction.PlainText
-p range
        Outputs predictions for test instances (or the train instances if
        no test instances provided and -no-cv is used), along with the
        attributes in the specified range (and nothing else).
        Use '-p 0' if no attributes are desired.
        Deprecated: use "-classifications ..." instead.
-distribution
        Outputs the distribution instead of only the prediction
        in conjunction with the '-p' option (only nominal classes).
        Deprecated: use "-classifications ..." instead.

例如,使用朴素贝叶斯算法处理天气数据集:
$ java weka.classifiers.bayes.NaiveBayes -t weather.nominal.arff -classifications weka.classifiers.evaluation.output.prediction.PlainText

=== Predictions under cross-validation ===

 inst#     actual  predicted error prediction
     1       2:no      1:yes   +   0.926
     2      1:yes      1:yes       0.825
     1       2:no      1:yes   +   0.636
     2      1:yes      1:yes       0.808
     1       2:no       2:no       0.718
     2      1:yes       2:no   +   0.656
     1       2:no      1:yes   +   0.579
     2      1:yes      1:yes       0.541
     1       2:no      1:yes   +   0.515
     1      1:yes       2:no   +   0.632
     1      1:yes      1:yes       0.84
     1      1:yes      1:yes       0.554
     1      1:yes      1:yes       0.757
     1      1:yes      1:yes       0.778

输出结果使用制表符分隔。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接