我正在尝试执行程序的主类,但遇到有关NullPointerException的错误,导致错误的方法如下
[]
我收到如下错误
线程“主”中的异常java.lang.NullPointerException
在CCA.Main.main(Main.java:361)
361行是
public double fitness(List<Double> position) {
double newFitness=0;
double[] features = NewMath.Position2Features(position_new);
Dataset[] foldsTem = new Dataset[problem.getNumFolds()];
for (int f = 0; f < problem.getNumFolds(); f++) {
foldsTem[f] = HelpDataset.removeFeatures(problem.getFoldsTrain()[f].copy(), features);
}
double accuracy = 0.0;//
for (int f = 0; f < problem.getNumFolds(); f++) { //10 fold cross validation
Dataset testTem = foldsTem[f];
Dataset trainTem = new DefaultDataset();
for (int j = 0; j < problem.getNumFolds(); j++) {
if (j != f) {
trainTem.addAll(foldsTem[j]);
}
}
accuracy += problem.getMyclassifier().classify(trainTem, testTem);
}
double error = 1.0 - accuracy / (double) problem.getNumFolds();
int size = HelpDataset.sizeSubset(features);
newFitness = 0.5* accuracy + 0.5 * ( (size) / (double) problem.getTraining().noAttributes());
return newFitness;
}
请提供任何帮助