0

我正在实现一个分类过滤器,它根据训练数据中存在的属性进行过滤。

//implement filter that standardizes via training set
Standardize filter = new Standardize();
filter.setInputFormat(trainingData);

//create a classifier
M5P m5p = new M5P();

//Create a filtered classified, set its filter and classifier
FilteredClassifier fc = new FilteredClassifier();
fc.setFilter(filter);
fc.setClassifier(m5p);

// train and make predictions
fc.buildClassifier(trainingData);
for (int i = 0; i < testingData.numInstances(); i++) {
    double pred = fc.classifyInstance(testingData.instance(i));
    System.out.print("ID: " + testingData.instance(i).value(0));
    System.out.print(", actual: " + testingData.classAttribute().value((int) testingData.instance(i).classValue()));
    System.out.println(", predicted: " + testingData.classAttribute().value((int) pred));
}

然后代码应该做出一些预测。但是,我得到空白输出。

ID: 6.0, actual: , predicted: 
ID: 4.0, actual: , predicted: 
ID: 4.0, actual: , predicted: 
ID: 5.0, actual: , predicted: 
ID: 5.0, actual: , predicted: 
ID: 4.0, actual: , predicted: 
ID: 4.0, actual: , predicted: 
ID: 7.0, actual: , predicted: 

有想法该怎么解决这个吗?谢谢!

4

0 回答 0