【发布时间】:2015-06-25 01:48:13
【问题描述】:
我正在使用 Weka 使用 LibSVM 分类器进行分类,并希望获得一些与我从评估模型获得的输出相关的帮助。
在下面的示例中,我的 test.arff 文件包含 1000 个实例,我想知道每个实例被分类为是/否的概率(这是一个简单的两类问题)。
例如,例如 1,如果它被归类为“是”,那么它被归类的概率是多少,是我正在寻找的东西。
下面是我目前拥有的代码sn-p:
// Read and load the Training ARFF file
ArffLoader trainArffLoader = new ArffLoader();
trainArffLoader.setFile(new File("train_clusters.arff"));
Instances train = trainArffLoader.getDataSet();
train.setClassIndex(train.numAttributes() - 1);
System.out.println("Loaded Train File");
// Read and load the Test ARFF file
ArffLoader testArffLoader = new ArffLoader();
testArffLoader.setFile(new File("test_clusters.arff"));
Instances test = testArffLoader.getDataSet();
test.setClassIndex(test.numAttributes() - 1);
System.out.println("Loaded Test File");
LibSVM libsvm = new LibSVM();
libsvm.buildClassifier(train);
// Evaluation
Evaluation evaluation = new Evaluation(train);
evaluation.evaluateModel(libsvm, test);
System.out.println(evaluation.toSummaryString("\nPrinting the Results\n=====================\n", true));
System.out.println(evaluation.toClassDetailsString());
【问题讨论】:
标签: machine-learning nlp classification weka