public class Evaluate {
public static void main(String args[]) throws Exception{
//load datasets
DataSource source = new DataSource("F:/data/solar_flare.arff");
Instances dataset = source.getDataSet();
BufferedReader reader = new BufferedReader(new FileReader("F:/data/solar_flare.arff"));
Instances training = new Instances(reader);
reader = new BufferedReader(new FileReader("F:/data/solar_flare.arff"));
Instances testing = new Instances(reader);
J48 jjjj = new J48();
MultilabelClassifier PS = new PS();
PS.setClassifier(jjjj);
PS.setOptions(Utils.splitOptions("-threshold PCut1 -verbosity 3"));
PS.buildClassifier(training);
Evaluation ecal = new Evaluation(training);
ecal.evaluateModel(PS, testing);
dataset.setClassIndex(dataset.numAttributes()-1);
J48 tree = new J48();
tree.buildClassifier(dataset);
Evaluation eval = new Evaluation(dataset);
Random rand = new Random(1);
int folds = 10;
DataSource source1 = new DataSource("F:/data/solar_flare.arff");
Instances testDataset = source1.getDataSet();
testDataset.setClassIndex(testDataset.numAttributes()-1);
eval.crossValidateModel(tree, testDataset, folds, rand);
System.out.println(eval.toMatrixString("=== Confusion Matrix ===\n"));
}
}
这是我的代码,它给出了错误回复
这是错误
"线程中的异常" main" java.lang.NoSuchMethodError: weka.core.Attribute。(Ljava / lang / String; Ljava / util / List;)V at meka.core.PSUtils.PSTransformation(PSUtils.java:416)at meka.classifiers.multilabel.PS.buildClassifier(PS.java:225)"在 Evaluate.main(Evaluate.java:57)
答案 0 :(得分:0)
当您使用的库的版本与您期望的版本不符时,这是一个典型的错误。您必须确保使用指定的方法在您的版本中存在weka.core.Attribute。