hubert39
04-18-2007, 03:44 AM
Hi,
I have trouble with evaluation function.
<my code>
J48Demo j48Demo = new J48Demo();
Instances trainInstances = j48Demo.ReadDBTrain();
trainInstances.setClassIndex(trainInstances.numAttributes()-1);
Instances testInstances = j48Demo.ReadDBTest();
testInstances.setClassIndex(testInstances.numAttributes()-1);
J48 j48 = new J48();
j48.buildClassifier(trainInstances);
Evaluation evaluation = new Evaluation(trainInstances);
evaluation.evaluateModel(j48, testInstances);
</my code>
However, the last line has some bugs as follows
<error>
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:1
at weka.classifiers.Evaluation.updateMargins(Evaluation.java:2656)
at weka.classifiers.Evaluation.updateStatsForClassifier(Evaluation.java:2516)
at weka.classifiers.Evaluation.evaluateModelOnceAndRecordPrediction(Evaluation.java:1084)
at weka.classifiers.Evaluation.evaluateModel(Evaluation.java:1053)
at weka.demo.J48Demo.main(J48Demo.java:63)
</error>
Can anyone help me solve this problem?
I'm very sure the trainInstances and testInstances have the same attribute number. Why are the testInstances out of bounds?:confused:
Sincerely,
Hubert
I have trouble with evaluation function.
<my code>
J48Demo j48Demo = new J48Demo();
Instances trainInstances = j48Demo.ReadDBTrain();
trainInstances.setClassIndex(trainInstances.numAttributes()-1);
Instances testInstances = j48Demo.ReadDBTest();
testInstances.setClassIndex(testInstances.numAttributes()-1);
J48 j48 = new J48();
j48.buildClassifier(trainInstances);
Evaluation evaluation = new Evaluation(trainInstances);
evaluation.evaluateModel(j48, testInstances);
</my code>
However, the last line has some bugs as follows
<error>
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:1
at weka.classifiers.Evaluation.updateMargins(Evaluation.java:2656)
at weka.classifiers.Evaluation.updateStatsForClassifier(Evaluation.java:2516)
at weka.classifiers.Evaluation.evaluateModelOnceAndRecordPrediction(Evaluation.java:1084)
at weka.classifiers.Evaluation.evaluateModel(Evaluation.java:1053)
at weka.demo.J48Demo.main(J48Demo.java:63)
</error>
Can anyone help me solve this problem?
I'm very sure the trainInstances and testInstances have the same attribute number. Why are the testInstances out of bounds?:confused:
Sincerely,
Hubert