public class Main {
public static void main(String[] args) throws IOException, Exception{
BufferedReader reader = new BufferedReader(
new FileReader("E:\\TRAIN.arff"));
Instances training = new Instances(reader);
BufferedReader reader1 = new BufferedReader(
new FileReader("E:\\TEST.arff"));
Instances test = new Instances(reader1);
NaiveBayes nb = new NaiveBayes();
//Use multilable classifier Binary Relevance (BR)
BR br = new BR();
//add naivebayes into BR
br.setClassifier(nb);
br.buildClassifier(training);
Evaluation eval = new Evaluation(training);
eval.evaluateModel(br,test);
}
}
我错了这段代码之后,错误显示:线程“main”中的异常weka.core.UnassignedClassException:未设置类!也许我错误地将naivebayes添加到BR分类器中,如何修改我的代码?
答案 0 :(得分:0)
您需要在数据集中选择属性,该属性将负责类标签。 例如:
training.setClass(data.attribute("NameOfAttribute"));