Hi,
strange results come up while using a J48 tree. I need to classify a vector of 48 features, which works very well, but when i tried to "optimize", I run into strange results.
I have a method classify:
public boolean classify(double feature1, double feature2, double[] featureVec ) {
Instance toBeClassified = new Instance(2+featureVec.length);
toBeClassified.setValue(0, feature1);
toBeClassified.setValue(1, feature2);
for (int i = 2; i < f.length + 2; ++i) {
toBeClassified.setValue(i, featureVec [i - 2]);
}
toBeClassified.setDataset(dataset);
try {
double _class = tree.classifyInstance(toBeClassified);
return _class > 0;
} catch (Exception e1) {
if(Logging.active) {
logger.error(e1.getMessage(), e1.getCause());}
}
return false;
}
}
It works quite well, and i hope i'm doing things right. But I wanted to remove the instance creation which is done at every method call, so I moved the Instance toBeClassified = new Instance(48); line into the class body - so it is created only once. That works well too, despite of the fact, that I get slightly different results compared with the other. lets say, from 400 classifications, one is different (not to say, incorrect). But I don't see a reason for this...I hope here are some guys using weka, so that I understand whats going on/wrong. (Yes, 2+featureVec.length is 48).
Thanks and regards.