RandomForest->predict always results 0
I am trying to predict an output from a feature vector. However the following code is always giving a result of 0. I have build a tree and trained it with many input of values 1 and 2 and I have saved this tree in the xml. When I try to predict the answer is always 0. Does anyone have an idea why this could happen ?
CvRTrees *aforest = new CvRTrees;
aforest->load("treeState.xml");
Mat predictionTraits(1, 250, CV_32FC1);
for(uint i = 0; i < featureVector.size(); i++){
predictionTraits.at<float>(0, i) = featureVector[i];
}
float result = aforest->predict(predictionTraits);
cout << "The result for this gesture has label" << result <<"\n" ;
Hi, I'm siso's teammate. I just wanted to add that we are trying to use CvRTrees with feature vectors of variable length, and we believe than the problem might originate from this. For instance, a feature vector could be [1,2,3,1,2] or [1,1,2,3,3,1,2] and represent the same output. I suppose we could pad the vectors with a certain value (such as 0), but how can we ensure that this value will be ignored by the classifier? We have tried using Mat masks to solve the issue, but it doesn't seem to help. Either there is a bug in our implementation, or CvRTrees cannot be used with variable length inputs.